12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace app\common\model;
- use think\Model;
- class Worder extends Model
- {
- // 设置字段信息
- protected $schema = [
- 'id' => 'int',
- 'cateid' => 'int',
- 'workerid' => 'int',
- 'title' => 'string',
- 'tags' => 'string',
- 'otype' => 'string',
- 'wagall' => 'string',
- 'telephone' => 'string',
- 'province' => 'string',
- 'city' => 'string',
- 'district' => 'string',
- 'jobdetails' => 'string',
- 'coodetails' => 'string',
- 'status' => 'tinyint',
- 'priority' => 'int',
- 'updatetime' => 'int',
- 'createtime' => 'int',
- 'volume' => 'int'
- ];
- // 设置字段自动转换类型
- protected $type = [
- 'tags' => 'json',
- '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']];
- }
-
- // 关联WorderCate
- public function worderCate()
- {
- return $this->hasOne(WorderCate::class, "id", "cateid");
- }
-
- // 关联Worker
- public function worker()
- {
- return $this->hasOne(Worker::class, "id", "workerid");
- }
-
- // 关联WorderLog
- public function worderLog()
- {
- return $this->hasMany(WorderLog::class, "worderid", "id");
- }
-
-
- }
|