'图片', self::RESOURCE_MODEL_VIDEO => '视频' ]; const TYPE_SYSTEM = 1; const TYPE_CUSTOM = 2; const STATUS_ON = 1; const STATUS_OFF = 0; const IS_TOP_ON = 1; const IS_TOP_OFF = 0; public static function tableName():string { return '{{%material}}'; } public function behaviors():array { return [ [ 'class' => TimestampBehavior::class, 'attributes' => [ \yii\db\BaseActiveRecord::EVENT_BEFORE_INSERT => ['create_time', 'update_time'], \yii\db\BaseActiveRecord::EVENT_BEFORE_UPDATE => ['update_time'], ], 'createdAtAttribute' => 'create_time', 'updatedAtAttribute' => 'update_time', 'value' => function(){ return date('Y-m-d H:i:s'); } ], ]; } public function rules():array { return [ [['store_id','material_category_id','type','status','sort','is_top','browsing_number','download_number','resource_model'],'integer'], [['promotion','promotion_image_f'],'string'], [['store_id','material_category_id','type','promotion','promotion_image'],'required'], ['browsing_number','default', 'value' => 0] ]; } public function attributeLabels():array { return [ 'store_id' => '店铺ID', 'material_category_id' => '素材分类ID', 'type' => '素材类型', 'promotion' => '素材推广', 'status' => '状态', 'is_top' => '是否置顶', 'sort' => '排序', 'browsing_number' => '浏览次数', 'promotion_image' => '推广图', 'promotion_image_f' => '推广方图' ]; } public function getMaterialCategory() { return $this->hasOne(MaterialCategory::class, ['id' => 'material_category_id']); } public function getMaterialResource(){ return $this->hasMany(MaterialResource::class, ['material_id' => 'id']); } public function getGoods(){ return $this->hasOne(Goods::class,['id'=>'goods_id'])->select('id,name,cover_pic,price'); } }