| | |
| | | use app\common\model\BaseModel; |
| | | use app\common\model\user\User as UserModel; |
| | | use app\common\model\branch\Branch as BranchModel; |
| | | use app\common\model\settings\Region; |
| | | |
| | | /** |
| | | * 连盟成员模型 |
| | |
| | | { |
| | | protected $name = 'branch_member'; |
| | | protected $pk = 'user_id'; |
| | | |
| | | /** |
| | | * 追加字段 |
| | | * @var string[] |
| | | */ |
| | | protected $append = ['region']; |
| | | |
| | | /** |
| | | * 关联所属分会表 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 关联职务 |
| | | */ |
| | | public function position() |
| | | { |
| | | return $this->belongsTo('app\\common\\model\\branch\\Position', 'position_id', 'position_id'); |
| | | } |
| | | |
| | | /** |
| | | * 籍贯 |
| | | * @param $value |
| | | * @param $data |
| | | * @return array |
| | | */ |
| | | public function getRegionAttr($value, $data) |
| | | { |
| | | if (!isset($data['province_id'])) { |
| | | return false; |
| | | } |
| | | return [ |
| | | 'province' => Region::getNameById($data['province_id']), |
| | | 'city' => Region::getNameById($data['city_id']), |
| | | 'region' => $data['region_id'] == 0 ? '' : Region::getNameById($data['region_id']), |
| | | ]; |
| | | } |
| | | |
| | | /** |
| | | * 详情 |
| | | */ |
| | | public static function detail($user_id, $with = ['user']) |