| | |
| | | |
| | | namespace app\common\model\plus\business; |
| | | use app\common\model\BaseModel; |
| | | use app\common\model\settings\Region; |
| | | |
| | | /** |
| | | * 名片管理模型 |
| | |
| | | class Business extends BaseModel |
| | | { |
| | | protected $name='business_card'; |
| | | /** |
| | | * 追加字段 |
| | | * @var string[] |
| | | */ |
| | | protected $append = ['region']; |
| | | |
| | | /** |
| | | * 地区名称 |
| | | * @param $value |
| | | * @param $data |
| | | * @return array |
| | | */ |
| | | public function getRegionAttr($value, $data) |
| | | { |
| | | return [ |
| | | 'province' => Region::getNameById($data['province_id']), |
| | | 'city' => Region::getNameById($data['city_id']), |
| | | 'region' => $data['region_id'] == 0 ? '' : Region::getNameById($data['region_id']), |
| | | ]; |
| | | } |
| | | public function getSexAttr($value){ |
| | | $data=[10=>'未知',20=>'男',30=>'女']; |
| | | return $data[$value]; |
| | |
| | | */ |
| | | public function add($data){ |
| | | $data['app_id']=self::$app_id; |
| | | $data['grade_id']=(new Grade())->getDefaultGradeId(); |
| | | return $this->save($data); |
| | | } |
| | | public function getUnitAttr($name) |
| | |
| | | } |
| | | return $this->with(['user','image','logoImage'])->order($order)->where($where)->paginate($paramr); |
| | | } |
| | | /** |
| | | * 获取名片详情 |
| | | * @param $business_card_id |
| | | * @return array|false|\think\Model|null |
| | | * @throws \think\db\exception\DbException |
| | | */ |
| | | public function detail($business_card_id){ |
| | | return $this->with(['user','image','logoImage'])->where(['business_card_id'=>$business_card_id])->find(); |
| | | } |
| | | } |