Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace backend\models;
- use Yii;
- use backend\models\Uslugi;
- /**
- * This is the model class for table "zayvki".
- *
- * @property int $id
- * @property int $user_id
- * @property int $status
- * @property int $master
- * @property int $uk
- * @property string $create_at
- * @property int $oplata_id
- * @property string $data_vyp
- *
- */
- class Zayvki extends \yii\db\ActiveRecord
- {
- public $uslugi_id;
- public $zayvki_id;
- public $typeuslug;
- public $category_id;
- public $hours;
- public $date;
- const STATUS_NEW = 1;
- const STATUS_WORK = 2;
- const STATUS_NONWORK = 3;
- const STATUS_FINISH = 4;
- const HOUSER2 = 2;
- const HOUSER4 = 4;
- const HOUSER6 = 6;
- const HOUSER8 = 8;
- const SERVICE_TYPES = [
- 1 => 'Услуга',
- 2 => 'Эконом',
- 3 => 'Доп. услуга',
- 4 => 'ОДН',
- ];
- public function getOrder(){
- return $this->hasOne(Order::className(), ['zayvki_id' => 'id']);
- }
- public function getUseruk(){
- return $this->hasOne(Users::className(), ['id' => 'uk']);
- }
- public function getUslugi(){
- return $this->hasOne(Uslugi::className(), ['id' => 'uslugi_id']);
- }
- public function getOplata(){
- return $this->hasOne(Oplata::className(), ['id' => 'oplata_id']);
- }
- public function getCategory(){
- return $this->hasOne(Category::className(), ['id' => 'category_id']);
- }
- public function getUser(){
- return $this->hasOne(Users::className(), ['id' => 'user_id']);
- }
- public static function statuses()
- {
- return [
- self::STATUS_NEW => 'Новая',
- self::STATUS_WORK => 'В работе',
- self::STATUS_NONWORK => 'Отклонена',
- self::STATUS_FINISH => 'Выполненая',
- ];
- }
- public static function houser()
- {
- return [
- self::HOUSER2 => '2 часа',
- self::HOUSER4 => '4 часов',
- self::HOUSER6 => '6 часов',
- self::HOUSER8 => '8 часов',
- ];
- }
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'zayvki';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['user_id'], 'required'],
- [['user_id', 'status', 'master', 'uk', 'oplata_id'], 'integer'],
- [['create_at'], 'safe'],
- [['status'], 'default', 'value' => 1],
- [['oplata_id'], 'default', 'value' => 1],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => '№ заявки',
- 'user_id' => 'Житель',
- 'status' => 'Статус',
- 'master' => 'Мастер',
- 'uk' => 'УК',
- 'create_at' => 'Дата заявки',
- 'oplata_id' => 'Способ оплаты',
- 'data_vyp' => 'Желаемое время',
- 'uslugi_id' => 'Услуга',
- 'typeName' => 'Тип услуги',
- 'koluslug' => 'Количество услуг',
- 'summa' => 'Сумма заявки',
- 'category_id' => 'Категория',
- ];
- }
- public function getTypeName()
- {
- $typeId = $this->order->uslugi->typeuslug;
- return self::SERVICE_TYPES[$typeId];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement