1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace app\common\model;
- use think\Model;
- use think\model\concern\SoftDelete;
- class Worker extends Model
- {
- use SoftDelete;
- protected $deleteTime = 'deletetime';
- protected $defaultSoftDelete = 0;
- // 设置字段信息
- protected $schema = [
- 'id' => 'int',
- 'userid' => 'int',
- 'wtype' => 'tinyint',
- 'title' => 'string',
- 'ftitle' => 'string',
- 'tilpic' => 'string',
- 'realname' => 'string',
- 'mobile' => 'string',
- 'weixin' => 'string',
- 'latitude' => 'float',
- 'longitude' => 'float',
- 'province' => 'string',
- 'city' => 'string',
- 'district' => 'string',
- 'address' => 'string',
- 'picone' => 'string',
- 'pictwo' => 'string',
- 'picthr' => 'string',
- 'details' => 'string',
- 'priority' => 'int',
- 'remark' => 'string',
- 'status' => 'tinyint',
- 'createtime' => 'int',
- 'is_public' => 'int',
- 'income' => 'decimal',
- 'income_total' => 'decimal',
- 'idcardzpic' => 'string',
- 'idcardfpic' => 'string',
- ];
- // 设置字段自动转换类型
- protected $type = [
- 'createtime' => 'timestamp:Y-m-d H:i:s',
- ];
- public function getWtypeTextAttr($value, $data)
- {
- $wtype = [1 => '个人雇主', 2 => '企业雇主'];
- return $wtype[$data['wtype']];
- }
- public function getStatusTextAttr($value, $data)
- {
- $status = [1 => '待审核', 2 => '未通过', 3 => '被禁用', 4 => '升级审核', 5 => '正常中'];
- return $status[$data['status']];
- }
- // 关联User
- public function muser()
- {
- return $this->hasOne(User::class, "id", "userid");
- }
- // 关联Agent
- public function agent()
- {
- return $this->hasMany(Agent::class, "workerid", "id");
- }
- // 关联Comjobs
- public function comjobs()
- {
- return $this->hasMany(Comjobs::class, "workerid", "id");
- }
- // 关联Demand
- public function demand()
- {
- return $this->hasMany(Demand::class, "workerid", "id");
- }
- }
|