1, 'max' => 999], [['report_name'], 'string', 'max' => 20], [['detection_agency'], 'string', 'max' => 4], [['images'], 'safe'], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'goods_id' => '商品ID', 'report_name' => '报告名称', 'detection_agency' => '检测方', 'detection_number' => '检测序号', 'detection_date' => '检测日期', 'images' => '检测图片', 'imageFiles' => '上传图片', 'created_at' => '创建时间', 'updated_at' => '更新时间', ]; } /** * 保存前处理 */ public function behaviors() { return [ [ 'class' => TimestampBehavior::class, 'attributes' => [ ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'], ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'] ] ] ]; } /** * 获取图片数组 */ public function getImageArray() { return $this->images ? Json::decode($this->images) : []; } /** * 关联商品 */ public function getProduct() { return $this->hasOne(Goods::class, ['id' => 'goods_id']); } }