'显示', self::IS_SHOW_HIDE => '隐藏' ]; /** * {@inheritdoc} */ public static function tableName() { return 'atg_category'; } /** * {@inheritdoc} */ public function rules() { return [ [['name'], 'required'], [['pid', 'goods_count', 'sort_order', 'is_show', 'is_delete', 'icon'], 'integer'], [['name'], 'string', 'max' => 60], [['iconImageId'], 'string'], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'id', 'name' => '类别名称', 'pid' => '父级', 'goods_count' => '商品数量', 'sort_order' => '排序', 'icon' => '图标', 'is_show' => '是否显示', 'is_delete' => '是否删除,1为已删除', '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']); } }