1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace app\common\model;
- use think\Model;
- use think\model\concern\SoftDelete;
- class Agent extends Model
- {
- use SoftDelete;
- protected $deleteTime = 'deletetime';
- protected $defaultSoftDelete = 0;
- // 设置字段信息
- protected $schema = [
- 'id' => 'int',
- 'userid' => 'int',
- 'workerid' => 'int',
- 'loginname' => 'string',
- 'password' => 'string',
- 'idnumber' => 'string',
- 'title' => 'string',
- 'tilpic' => 'string',
- 'picall' => 'string',
- 'realname' => 'string',
- 'mobile' => 'string',
- 'telephone' => 'string',
- 'latitude' => 'float',
- 'longitude' => 'float',
- 'province' => 'string',
- 'city' => 'string',
- 'district' => 'string',
- 'address' => 'string',
- 'details' => 'string',
- 'priority' => 'int',
- 'remark' => 'string',
- 'status' => 'tinyint',
- 'createtime' => 'int',
- 'wxampcode' => 'string'
- ];
-
- // 设置字段自动转换类型
- protected $type = [
- 'picall' => 'json',
- 'createtime' => 'timestamp:Y-m-d H:i:s'
- ];
- protected $jsonAssoc = true;
-
- public function getStatusTextAttr($value,$data)
- {
- $status = [1=>'正常',2=>'禁用'];
- return $status[$data['status']];
- }
-
- // 关联User
- public function muser()
- {
- return $this->hasOne(User::class, "id", "userid");
- }
-
- // 关联Worker
- public function worker()
- {
- return $this->hasOne(Worker::class, "id", "workerid");
- }
-
- // 关联Broker
- public function broker()
- {
- return $this->hasMany(Broker::class, "agentid", "id");
- }
-
- // 关联Partjob
- public function partjob()
- {
- return $this->hasMany(Partjob::class, "agentid", "id");
- }
-
- }
|