Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. <?php
  2.  
  3. namespace backend\models;
  4.  
  5. use Yii;
  6. use backend\models\Uslugi;
  7.  
  8.  
  9. /**
  10. * This is the model class for table "zayvki".
  11. *
  12. * @property int $id
  13. * @property int $user_id
  14. * @property int $status
  15. * @property int $master
  16. * @property int $uk
  17. * @property string $create_at
  18. * @property int $oplata_id
  19. * @property string $data_vyp
  20.  
  21. *
  22. */
  23. class Zayvki extends \yii\db\ActiveRecord
  24. {
  25. public $uslugi_id;
  26. const STATUS_NEW = 1;
  27. const STATUS_WORK = 2;
  28. const STATUS_NONWORK = 3;
  29. const STATUS_FINISH = 4;
  30.  
  31. public function getOrder(){
  32. return $this->hasOne(Order::className(), ['zayvki_id' => 'id']);
  33. }
  34. public function getUseruk(){
  35. return $this->hasOne(Users::className(), ['id' => 'uk']);
  36. }
  37. public function getUslugi(){
  38. return $this->hasOne(Uslugi::className(), ['id' => 'uslugi_id']);
  39. }
  40. public function getUser(){
  41. return $this->hasOne(Users::className(), ['id' => 'user_id']);
  42. }
  43. public static function statuses()
  44. {
  45. return [
  46. self::STATUS_NEW => 'Новая',
  47. self::STATUS_WORK => 'В работе',
  48. self::STATUS_NONWORK => 'Отклонена',
  49. self::STATUS_FINISH => 'Выполненая',
  50. ];
  51. }
  52.  
  53. /**
  54. * {@inheritdoc}
  55. */
  56. public static function tableName()
  57. {
  58. return 'zayvki';
  59. }
  60.  
  61. /**
  62. * {@inheritdoc}
  63. */
  64. public function rules()
  65. {
  66. return [
  67. [['user_id'], 'required'],
  68. [['user_id', 'status', 'master', 'uk', 'oplata_id'], 'integer'],
  69. [['create_at'], 'safe'],
  70. [['status'], 'default', 'value' => 1],
  71. [['oplata_id'], 'default', 'value' => 1],
  72. ];
  73. }
  74.  
  75. /**
  76. * {@inheritdoc}
  77. */
  78. public function attributeLabels()
  79. {
  80. return [
  81. 'id' => '№ заявки',
  82. 'user_id' => 'Житель',
  83. 'status' => 'Статус',
  84. 'master' => 'Мастер',
  85. 'uk' => 'УК',
  86. 'create_at' => 'Дата заявки',
  87. 'oplata_id' => 'Способ оплаты',
  88. 'data_vyp' => 'Желаемое время',
  89. 'uslugi_id' => "Услуга"
  90. ];
  91. }
  92. public static function getDropDown(){
  93. return ArrayHelper::map(self::find()->all(),'id','usluginame');
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement