'шт.', self::TYPE_WEIGHT => 'кг.', ]; } /** * @return string[] */ public static function getStatus(): array { return [ self::STATUS_ACTIVE => 'Активна', self::STATUS_INACTIVE => 'Не активна', ]; } /** * {@inheritdoc} */ public static function tableName(): string { return 'product'; } /** * {@inheritdoc} */ public function rules(): array { return [ [['title', 'article', 'company_id', 'product_category_id'], 'required'], [['company_id', 'type', 'price', 'status', 'product_category_id'], 'integer'], [['title', 'article'], 'string', 'max' => 255], [['company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::class, 'targetAttribute' => ['company_id' => 'id']], ]; } /** * {@inheritdoc} */ public function attributeLabels(): array { return [ 'id' => 'ID', 'title' => 'Название', 'article' => 'Артикул', 'company_id' => 'Компания', 'type' => 'Тип', 'price' => 'Цена', 'status' => 'Статус', 'product_category_id' => 'Категория', ]; } /** * Gets query for [[Company]]. * * @return \yii\db\ActiveQuery */ public function getCompany(): \yii\db\ActiveQuery { return $this->hasOne(Company::class, ['id' => 'company_id']); } /** * @return \yii\db\ActiveQuery */ public function getProductCategory(): \yii\db\ActiveQuery { return $this->hasOne(ProductCategory::class, ['id' => 'product_category_id']); } }