Advertisement
pmtpenza

Untitled

Jun 25th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 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. */
  24. class Zayvki extends \yii\db\ActiveRecord
  25. {
  26. public $uslugi_id;
  27. public $zayvki_id;
  28. public $typeuslug;
  29. public $category_id;
  30. public $hours;
  31. public $date;
  32. const STATUS_NEW = 1;
  33. const STATUS_WORK = 2;
  34. const STATUS_NONWORK = 3;
  35. const STATUS_FINISH = 4;
  36.  
  37. const HOUSER2 = 2;
  38. const HOUSER4 = 4;
  39. const HOUSER6 = 6;
  40. const HOUSER8 = 8;
  41.  
  42. const SERVICE_TYPES = [
  43. 1 => 'Услуга',
  44. 2 => 'Эконом',
  45. 3 => 'Доп. услуга',
  46. 4 => 'ОДН',
  47. ];
  48.  
  49.  
  50. public function getOrder(){
  51. return $this->hasOne(Order::className(), ['zayvki_id' => 'id']);
  52. }
  53. public function getUseruk(){
  54. return $this->hasOne(Users::className(), ['id' => 'uk']);
  55. }
  56. public function getUslugi(){
  57. return $this->hasOne(Uslugi::className(), ['id' => 'uslugi_id']);
  58. }
  59. public function getOplata(){
  60. return $this->hasOne(Oplata::className(), ['id' => 'oplata_id']);
  61. }
  62. public function getCategory(){
  63. return $this->hasOne(Category::className(), ['id' => 'category_id']);
  64. }
  65.  
  66. public function getUser(){
  67. return $this->hasOne(Users::className(), ['id' => 'user_id']);
  68. }
  69. public static function statuses()
  70. {
  71. return [
  72. self::STATUS_NEW => 'Новая',
  73. self::STATUS_WORK => 'В работе',
  74. self::STATUS_NONWORK => 'Отклонена',
  75. self::STATUS_FINISH => 'Выполненая',
  76. ];
  77. }
  78. public static function houser()
  79. {
  80. return [
  81. self::HOUSER2 => '2 часа',
  82. self::HOUSER4 => '4 часов',
  83. self::HOUSER6 => '6 часов',
  84. self::HOUSER8 => '8 часов',
  85. ];
  86. }
  87.  
  88.  
  89. /**
  90. * {@inheritdoc}
  91. */
  92. public static function tableName()
  93. {
  94. return 'zayvki';
  95. }
  96.  
  97. /**
  98. * {@inheritdoc}
  99. */
  100. public function rules()
  101. {
  102. return [
  103. [['user_id'], 'required'],
  104. [['user_id', 'status', 'master', 'uk', 'oplata_id'], 'integer'],
  105. [['create_at'], 'safe'],
  106. [['status'], 'default', 'value' => 1],
  107. [['oplata_id'], 'default', 'value' => 1],
  108. ];
  109. }
  110.  
  111. /**
  112. * {@inheritdoc}
  113. */
  114. public function attributeLabels()
  115. {
  116. return [
  117. 'id' => '№ заявки',
  118. 'user_id' => 'Житель',
  119. 'status' => 'Статус',
  120. 'master' => 'Мастер',
  121. 'uk' => 'УК',
  122. 'create_at' => 'Дата заявки',
  123. 'oplata_id' => 'Способ оплаты',
  124. 'data_vyp' => 'Желаемое время',
  125. 'uslugi_id' => 'Услуга',
  126. 'typeName' => 'Тип услуги',
  127. 'koluslug' => 'Количество услуг',
  128. 'summa' => 'Сумма заявки',
  129. 'category_id' => 'Категория',
  130. ];
  131. }
  132. public function getTypeName()
  133. {
  134. $typeId = $this->order->uslugi->typeuslug;
  135. return self::SERVICE_TYPES[$typeId];
  136. }
  137.  
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement