| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- /**
- * 厦门云联储网络科技有限公司
- * https://www.baokuaiyun.com
- * Copyright (c) 2023 爆块云 All rights reserved.
- */
- namespace app\models;
- use yii\behaviors\TimestampBehavior;
- use yii\db\ActiveRecord;
- use yii\helpers\Json;
- /**
- * 商品检测报告模型
- *
- * @property int $id
- * @property int $goods_id 商品ID
- * @property int $store_id
- * @property string $report_name 报告名称
- * @property string $detection_agency 检测方
- * @property int $detection_number 检测序号
- * @property string $detection_date 检测日期
- * @property string $images 图片路径
- * @property int $created_at
- * @property int $is_delete
- * @property int $updated_at
- */
- class GoodsDetection extends ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%goods_detection}}';
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['goods_id', 'report_name', 'detection_agency', 'detection_number', 'detection_date'], 'required'],
- [['goods_id','store_id', 'detection_number','is_delete', 'created_at', 'updated_at', 'detection_date'], 'integer'],
- [['detection_number'], 'integer', 'min' => 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']);
- }
- }
|