| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\plugins\food\models;
- use yii\db\ActiveRecord;
- use yii\behaviors\TimestampBehavior;
- /**
- * Class Goods
- * @package app\modules\common\models
- * @property integer $id
- * @property integer $store_id
- * @property string $name
- * @property string $subtitle
- * @property string $price
- * @property string $original_price
- * @property string $detail
- * @property string $cat_id
- * @property integer $status
- * @property integer $is_delete
- * @property string $attr
- * @property integer $sort
- * @property integer $virtual_sales
- * @property integer $is_recommend
- * @property string $cover_pic
- * @property string $material_id
- * @property string $created_at
- * @property string $updated_at
- */
- class FoodGoods extends ActiveRecord
- {
- const STATUS_NORMAL = 1; // 上架
- const STATUS_DISABLE = 0; // 下架
- public static function tableName()
- {
- return '{{%food_goods}}';
- }
- public function behaviors()
- {
- return [
- [
- // 自动更新创建和更新时间
- 'class' => TimestampBehavior::class,
- 'value' => time()
- ]
- ];
- }
- public function rules()
- {
- return [
- [['store_id', 'name', 'detail', 'attr'], 'required', 'on' => self::whenSave()],
- [['store_id', 'cat_id', 'status', 'is_delete', 'created_at', 'updated_at',
- 'sort', 'virtual_sales', 'is_recommend'], 'integer', 'on' => self::whenSave()],
- [['price', 'original_price'], 'number', 'on' => self::whenSave()],
- [['detail', 'attr', 'cover_pic', 'subtitle'], 'string', 'on' => self::whenSave()],
- [['name', 'material_id'], 'string', 'max' => 255, 'on' => self::whenSave()],
- [['status', 'cat_id', 'store_id'], 'integer', 'on' => self::whenList()],
- [['name'], 'string', 'max' => 60, 'on' => self::whenList()],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'store_id' => 'Store ID',
- 'name' => '商品名称',
- 'subtitle' => '副标题',
- 'price' => '售价',
- 'original_price' => '原价(只做显示用)',
- 'detail' => '商品详情,图文',
- 'cat_id' => '商品类别',
- 'status' => '上架状态:0=下架,1=上架',
- 'is_delete' => 'Is Delete',
- 'attr' => '规格的库存及价格',
- 'sort' => '排序 升序',
- 'virtual_sales' => '虚拟销量',
- 'is_recommend' => '是否推荐',
- 'cover_pic' => '商品缩略图',
- 'material_id' => '图片物料id',
- 'created_at' => '创建时间',
- 'updated_at' => '更新时间',
- ];
- }
- public static function whenSave ()
- {
- return 'save';
- }
- public static function whenList ()
- {
- return 'list';
- }
- }
|