12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace app\common\model;
- use think\Model;
- use think\model\concern\SoftDelete;
- class Broker extends Model
- {
- use SoftDelete;
- protected $deleteTime = 'deletetime';
- protected $defaultSoftDelete = 0;
- // 设置字段信息
- protected $schema = [
- 'id' => 'int',
- 'userid' => 'int',
- 'workerid' => 'int',
- 'agentid' => 'int',
- 'title' => 'string',
- 'mobile' => 'string',
- 'weixin' => 'string',
- 'qq' => 'string',
-
- 'province' => 'string',
- 'city' => 'string',
- 'district' => 'string',
- 'details' => 'string',
-
- 'status' => 'tinyint',
- 'powerreport' => 'tinyint',
- 'createtime' => 'int'
- ];
-
- // 设置字段自动转换类型
- protected $type = [
- 'createtime' => 'timestamp:Y-m-d H:i:s'
- ];
-
- public function getStatusTextAttr($value,$data)
- {
- $status = [1=>'正常',2=>'禁用'];
- return $status[$data['status']];
- }
-
- public function getPowerreportTextAttr($value,$data)
- {
- $status = [1=>'是',2=>'否'];
- return $status[$data['powerreport']];
- }
-
-
- // 关联User
- public function muser()
- {
- return $this->hasOne(User::class, "id", "userid");
- }
-
- // 关联Worker
- public function worker()
- {
- return $this->hasOne(Worker::class, "id", "workerid");
- }
-
- // 关联Agent
- public function agent()
- {
- return $this->hasOne(Agent::class, "id", "agentid");
- }
-
- // 关联User
- public function user()
- {
- return $this->hasMany(User::class, "brokerid", "id");
- }
-
- }
|