You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
2.8 KiB
125 lines
2.8 KiB
<?php
|
|
|
|
namespace backend\models;
|
|
|
|
use iron\wegets\Upload;
|
|
use Yii;
|
|
use yii\behaviors\TimestampBehavior;
|
|
|
|
/**
|
|
* This is the model class for table "category".
|
|
*
|
|
* @property int $id
|
|
* @property string $cat_name
|
|
* @property string $icon
|
|
* @property int $icon_type
|
|
* @property string $description
|
|
* @property int $sort_order
|
|
* @property int $created_at
|
|
* @property int $updated_at
|
|
*/
|
|
class Category extends \yii\db\ActiveRecord
|
|
{
|
|
|
|
const ICON_TYPE_BOOSTARAP = 1;
|
|
const ICON_TYPE_AWESOME = 2;
|
|
|
|
public static $iconType = [
|
|
self::ICON_TYPE_BOOSTARAP => "boostrap",
|
|
self::ICON_TYPE_AWESOME => "awesome"
|
|
];
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public static function tableName()
|
|
{
|
|
return 'category';
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['icon_type', 'cat_name', 'created_at'], 'required'],
|
|
[['icon_type', 'sort_order', 'created_at', 'updated_at'], 'integer'],
|
|
[['description'], 'string'],
|
|
[['cat_name', 'icon'], 'string', 'max' => 64],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function attributeLabels()
|
|
{
|
|
return [
|
|
'id' => 'ID',
|
|
'cat_name' => '类名',
|
|
'icon' => 'Icon',
|
|
'icon_type' => '图标类型',
|
|
'description' => '描述',
|
|
'sort_order' => 'Sort Order',
|
|
'created_at' => '添加日期',
|
|
'updated_at' => 'Updated At',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
* 列格式
|
|
*/
|
|
public static function columns()
|
|
{
|
|
return [
|
|
[
|
|
'class' => 'blobt\grid\CheckboxColumn',
|
|
'width' => '2%',
|
|
'align' => 'center'
|
|
],
|
|
[
|
|
'attribute' => 'id',
|
|
'width' => '10%',
|
|
'align' => 'center'
|
|
],
|
|
[
|
|
'attribute' => 'created_at',
|
|
'width' => '10%',
|
|
'format' => 'date'
|
|
],
|
|
[
|
|
'attribute' => 'cat_name',
|
|
'width' => '10%',
|
|
],
|
|
[
|
|
'attribute' => 'icon',
|
|
'width' => '10%',
|
|
],
|
|
[
|
|
'attribute' => 'icon_type',
|
|
'width' => '10%',
|
|
'showConstText' => true
|
|
],
|
|
[
|
|
'attribute' => 'description',
|
|
'enableSorting' => false,
|
|
'format' => 'ntext',
|
|
'width' => '20%',
|
|
],
|
|
[
|
|
'class' => 'iron\grid\ActionColumn',
|
|
'align' => 'center',
|
|
],
|
|
];
|
|
}
|
|
|
|
public function behaviors()
|
|
{
|
|
return [
|
|
TimestampBehavior::className()
|
|
];
|
|
}
|
|
|
|
}
|