255], [['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => Category::class, 'targetAttribute' => ['category_id' => 'id']], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'type' => 'Type', 'name' => 'Name', 'description' => 'Description', 'price' => 'Price', 'status' => 'Status', 'quantity' => 'Quantity', 'taste' => 'Taste', 'strength' => 'Strength', 'category_id' => 'Category ID', ]; } /** * Gets query for [[Category]]. * * @return \yii\db\ActiveQuery */ public function getCategory() { return $this->hasOne(Category::class, ['id' => 'category_id']); } /** * Gets query for [[OrderProducts]]. * * @return \yii\db\ActiveQuery */ public function getOrderProducts() { return $this->hasMany(OrderProduct::class, ['product_id' => 'id']); } /** * Gets query for [[Orders]]. * * @return \yii\db\ActiveQuery */ public function getOrders() { return $this->hasMany(Order::class, ['id' => 'product_id']) ->viaTable('order_product', ['order_id' => 'id']); } public static function TypesWIthLabels() { return [ 0 => 'другое', 1 => 'табак' ]; } public static function TabacooStrengthWithLabel() { return [ 0 => 'Легкий', 1 => 'Средний', 2 => 'Тяжелый' ]; } }