<?php namespace common\models; use Yii; /** * This is the model class for table "check". * * @property int $id * @property string $number * @property int $company_id * @property string $additional * @property string $title * @property int $addresses_id * @property int|null $status * * @property Addresses $addresses * @property Company $company */ class Check extends \yii\db\ActiveRecord { const STATUS_NEW = 1; const STATUS_PRINTED = 2; const STATUS_PAID = 3; /** * @return string[] */ public static function getStatus(): array { return [ self::STATUS_NEW => 'Новый', self::STATUS_PRINTED => 'Напечатан', self::STATUS_PAID => 'Оплачен', ]; } /** * @return string[] */ public static function getStatusColor(): array { return [ self::STATUS_NEW => '#FFA500', self::STATUS_PRINTED => '#008080', self::STATUS_PAID => '#32CD32', ]; } /** * {@inheritdoc} */ public static function tableName() { return 'check'; } /** * {@inheritdoc} */ public function rules() { return [ [['number', 'company_id', 'addresses_id'], 'required'], [['company_id', 'addresses_id', 'status'], 'integer'], [['number', 'title'], 'string', 'max' => 255], [['additional'], 'string'], [['addresses_id'], 'exist', 'skipOnError' => true, 'targetClass' => Addresses::class, 'targetAttribute' => ['addresses_id' => 'id']], [['company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::class, 'targetAttribute' => ['company_id' => 'id']], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'number' => 'Номер', 'company_id' => 'Компания', 'additional' => 'Дополнительная информация', 'title' => 'Заголовок', 'addresses_id' => 'Отделение', 'status' => 'Статус', ]; } /** * Gets query for [[Addresses]]. * * @return \yii\db\ActiveQuery */ public function getAddresses(): \yii\db\ActiveQuery { return $this->hasOne(Addresses::class, ['id' => 'addresses_id']); } /** * Gets query for [[Company]]. * * @return \yii\db\ActiveQuery */ public function getCompany(): \yii\db\ActiveQuery { return $this->hasOne(Company::class, ['id' => 'company_id']); } }