add product category crud + model ( termék kategória )

This commit is contained in:
2015-09-21 10:35:15 +02:00
parent 8890727862
commit 6b81ced4ba
13 changed files with 537 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "product_category".
*
* @property integer $id_product_category
* @property string $name
* @property integer $status
* @property string $created_at
* @property string $updated_at
*/
class ProductCategory extends \common\models\BaseFitnessActiveRecord
{
const STATUS_DELETED = 0;
const STATUS_ACTIVE = 10;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'product_category';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name'], 'required'],
[['status'], 'integer'],
[['name'], 'string', 'max' => 64]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id_product_category' => Yii::t('common/product_category', 'Id Product Category'),
'name' => Yii::t('common/product_category', 'Name'),
'status' => Yii::t('common/product_category', 'Status'),
'created_at' => Yii::t('common/product_category', 'Created At'),
'updated_at' => Yii::t('common/product_category', 'Updated At'),
];
}
static function statuses() {
return [
self::STATUS_ACTIVE => Yii::t('common/product_category', 'Active'),
self::STATUS_DELETED => Yii::t('common/product_category', 'Inactive'),
];
}
public function getStatusHuman(){
$result = null;
$s = self::statuses($this->status);
if ( array_key_exists($this->status, $s)){
$result = $s[$this->status];
}
return $result;
}
}