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.
122 lines
3.1 KiB
122 lines
3.1 KiB
<?php
|
|
|
|
namespace antgoods\models\ars;
|
|
|
|
use Yii;
|
|
use yii\behaviors\TimestampBehavior;
|
|
use common\models\ars\File;
|
|
|
|
/**
|
|
* This is the model class for table "antgoods_shop_category".
|
|
*
|
|
* @property int $id
|
|
* @property string $name 类别名称
|
|
* @property int $pid 父级id
|
|
* @property int $goods_count 商品数量
|
|
* @property string $keywords 关键字
|
|
* @property string $desc 描述
|
|
* @property int $sort_order 排序
|
|
* @property string $icon 图标
|
|
* @property string $filter_attr 筛选属性
|
|
* @property int $is_show 是否显示,1为不显示
|
|
* @property int $is_delete 是否删除,1为已删除
|
|
* @property int $created_at 创建时间
|
|
* @property int $updated_at 更新时间
|
|
*/
|
|
class ShopCategory extends \yii\db\ActiveRecord
|
|
{
|
|
public $iconImageId;
|
|
public $iconImagePath;
|
|
//是否显示is_show
|
|
const IS_SHOW_DISPLAY = 0;//显示
|
|
const IS_SHOW_HIDE = 1;//隐藏
|
|
//是否删除is_delete
|
|
const IS_DELETE_NO = 0;//未删除
|
|
const IS_DELETE_YES = 1;//已删除
|
|
|
|
public static $isShow = [
|
|
self::IS_SHOW_DISPLAY => '显示',
|
|
self::IS_SHOW_HIDE => '隐藏'
|
|
];
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public static function tableName()
|
|
{
|
|
return 'antgoods_shop_category';
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['name'], 'required'],
|
|
[['pid', 'goods_count', 'sort_order', 'icon', 'is_show', 'is_delete', 'iconImageId'], 'integer'],
|
|
[['filter_attr'], 'safe'],
|
|
[['name'], 'string', 'max' => 60],
|
|
[['keywords'], 'string', 'max' => 100],
|
|
[['desc'], 'string', 'max' => 255],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function attributeLabels()
|
|
{
|
|
return [
|
|
'id' => 'id',
|
|
'name' => '类别名称',
|
|
'pid' => '父级',
|
|
'goods_count' => '商品数量',
|
|
'keywords' => '关键字',
|
|
'desc' => '描述',
|
|
'sort_order' => '排序',
|
|
'icon' => '图标',
|
|
'filter_attr' => '筛选属性',
|
|
'is_show' => '是否显示',
|
|
'is_delete' => '是否删除',
|
|
'created_at' => '创建时间',
|
|
'updated_at' => '更新时间',
|
|
];
|
|
}
|
|
|
|
|
|
/**
|
|
* @author linyao
|
|
* @email 602604991@qq.com
|
|
* @created Nov 8, 2019
|
|
*
|
|
* 行为存储创建时间和更新时间
|
|
*/
|
|
public function behaviors()
|
|
{
|
|
return [
|
|
[
|
|
'class' => TimestampBehavior::className(),
|
|
'createdAtAttribute' => 'created_at',
|
|
'updatedAtAttribute' => 'updated_at',
|
|
'value' => function() {
|
|
return time();
|
|
},
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
* 数据键值对
|
|
*/
|
|
public static function modelColumn()
|
|
{
|
|
return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->indexBy('id')->column();
|
|
}
|
|
|
|
public function getIconFile()
|
|
{
|
|
return $this->hasOne(File::className(), ['id' => 'icon']);
|
|
}
|
|
}
|