255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'cx_mch_id' => '平台商户ID', 'name' => '商品名称', 'subtitle' => '副标题', 'original_price' => '原价', 'cost_price' => '成本价', 'detail' => '商品详情,图文', 'cover_pic' => '商品缩略图', 'pic_urls' => '商品轮播图', 'video_url' => '商品视频', 'unit' => '单位', 'created_at' => '添加时间', 'updated_at' => '更新时间', 'deleted_at' => '删除时间', 'is_delete' => '是否删除,0=否,1=是', 'type' => '商品类型:0=实体商品 ', ]; } public function beforeSave($insert) { if(parent::beforeSave($insert)){ if($this->isNewRecord){ $this->created_at = time(); } $this->updated_at = time(); if($this->is_delete == 1) $this->deleted_at = time(); $this->htmlTagFilter(); return true; } else { return false; } } public function htmlTagFilter() { $this->name = Model::htmlTagFilter($this->name); $this->subtitle = Model::htmlTagFilter($this->subtitle); $this->detail = Model::htmlTagFilter($this->detail); $this->cover_pic = Model::htmlTagFilter($this->cover_pic); $this->video_url = Model::htmlTagFilter($this->video_url); $this->unit = Model::htmlTagFilter($this->unit); } }