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,36 @@
<?php
/**
* Message translations.
*
* This file is automatically generated by 'yii message' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
* Each array element represents the translation (value) of a message (key).
* If the value is empty, the message is considered as not translated.
* Messages that no longer need translation will have their translations
* enclosed between a pair of '@@' marks.
*
* Message string can be used with plural forms format. Check i18n section
* of the guide for details.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Active' => 'Aktív',
'Are you sure you want to delete this item?' => 'Biztosan törölni szeretné a termék kategóriát?',
'Create' => 'Mentés',
'Create Product Category' => 'Új termék kategória',
'Created At' => 'Létrehozás ideje',
'Delete' => 'Törlés',
'Id Product Category' => 'Azonosító',
'Inactive' => 'Inaktív',
'Name' => 'Név',
'Product Categories' => 'Termék kategóriák',
'Product Category' => 'Termék kategória',
'Search' => 'Keresés',
'Status' => 'Státusz',
'Update' => 'Módosítás',
'Update {modelClass}: ' => '{modelClass} módosítása:',
'Updated At' => 'Módosítás ideje',
];

View File

@@ -0,0 +1,21 @@
<?php
namespace common\models;
use yii\helpers\ArrayHelper;
use yii\behaviors\TimestampBehavior;
class BaseFitnessActiveRecord extends \yii\db\ActiveRecord{
/**
* @inheritdoc
*/
public function behaviors()
{
return ArrayHelper::merge( [
[
'class' => TimestampBehavior::className(),
'value' => function(){ return date('Y-m-d H:i:s' ); }
]
], parent::behaviors());
}
}

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;
}
}