1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace app\common\model;
- use think\Model;
- class BrokerForm extends Model
- {
- // 设置字段信息
- protected $schema = [
- 'id' => 'int',
- 'userid' => 'int',
- 'workerid' => 'int',
- 'agentid' => 'int',
- 'title' => 'string',
- 'avatar' => 'string',
- 'mobile' => 'string',
- 'province' => 'string',
- 'city' => 'string',
- 'district' => 'string',
- 'town' => 'string',
- 'village' => 'string',
- 'region' => 'string',
- 'createtime' => 'int',
- 'status' => 'tinyint',
- ];
- // 设置字段自动转换类型
- protected $type = [
- 'createtime' => 'timestamp:Y-m-d H:i:s',
- ];
- public function getStatusTextAttr($value, $data)
- {
- $status = [1 => '待审核', 2 => '审核通过', 3 => '审核拒绝'];
- return $status[$data['status']];
- }
- // 关联Worker
- public function worker()
- {
- return $this->hasOne(Worker::class, "id", "workerid");
- }
- // 关联Agent
- public function agent()
- {
- return $this->hasOne(Agent::class, "id", "agentid");
- }
- }
|