20], [['description'], 'string', 'max' => 255] ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id_product' => Yii::t('common/product', 'Id Product'), 'id_product_type' => Yii::t('common/product', 'Id Product Type'), 'id_account' => Yii::t('common/product', 'Id Account'), 'product_number' => Yii::t('common/product', 'Product Number'), 'barcode' => Yii::t('common/product', 'Barcode'), 'purchase_price' => Yii::t('common/product', 'Purchase Price'), 'sale_price' => Yii::t('common/product', 'Sale Price'), 'profit_margins' => Yii::t('common/product', 'Profit Margins'), 'status' => Yii::t('common/product', 'Status'), 'description' => Yii::t('common/product', 'Description'), 'created_at' => Yii::t('common/product', 'Created At'), 'updated_at' => Yii::t('common/product', 'Updated At'), ]; } public function getAccount() { return $this->hasOne ( Account::className (), [ 'id_account' => 'id_account' ] ); } public function getAccountName() { return $this->account->name; } public function getProductCategory() { return $this->hasOne ( ProductCategory::className (), [ 'id_product_category' => 'id_product_category' ] ); } public function getProductCategoryName() { return $this->productCategory->name; } /** * @formatter:on */ static function statuses() { return [ self::STATUS_ACTIVE => Yii::t ( 'common/product', 'Active' ), self::STATUS_DELETED => Yii::t ( 'common/product', 'Inactive' ) ]; } public function getStatusHuman() { $result = null; $s = self::statuses ( ); if (array_key_exists ( $this->status, $s )) { $result = $s [$this->status]; } return $result; } }