123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace app\common\model;
- use think\Model;
- use think\model\concern\SoftDelete;
- class Supply extends Model
- {
- use SoftDelete;
- protected $deleteTime = 'deletetime';
- protected $defaultSoftDelete = 0;
- // 设置字段信息
- protected $schema = [
- 'id' => 'int',
- 'workerid' => 'int',
- 'mnumber' => 'int',
- 'wnumber' => 'int',
- 'agegroup' => 'string',
- 'province' => 'string',
- 'city' => 'string',
- 'district' => 'string',
- 'descity' => 'string',
- 'candate' => 'string',
- 'telephone' => 'string',
- 'remark' => 'string',
- 'status' => 'tinyint',
- 'priority' => 'int',
- 'updatetime' => 'int',
- 'createtime' => 'int',
- 'volume' => 'int',
- 'telearr' => 'string'
- ];
- // 设置字段自动转换类型
- protected $type = [
- 'telearr' => 'json',
- 'candate' => 'timestamp:Y-m-d',
- 'updatetime' => 'timestamp:Y-m-d H:i:s',
- 'createtime' => 'timestamp:Y-m-d H:i:s'
- ];
- // 设置JSON数据返回数组
- protected $jsonAssoc = true;
-
- public function getStatusTextAttr($value,$data)
- {
- $status = [1=>'待修改',2=>'待审核',3=>'已上架',4=>'已停供',5=>'已下架'];
- return $status[$data['status']];
- }
- // 关联Worker
- public function worker()
- {
- return $this->hasOne(Worker::class, "id", "workerid");
- }
-
- }
|