调整公司返回字段
This commit is contained in:
parent
e119d0b124
commit
7969344bb6
@ -36,10 +36,11 @@ class CompanyController extends BaseApiController
|
||||
$id = $this->request->param('id', 0);
|
||||
if (empty($id)) {
|
||||
$admin = Admin::findOrEmpty($this->userInfo['admin_id']);
|
||||
$company = Company::findOrEmpty($admin['company_id'])->toArray();
|
||||
$query = Company::find($admin['company_id']);
|
||||
} else {
|
||||
$company = Company::findOrEmpty($id)->toArray();
|
||||
$query = Company::find($id);
|
||||
}
|
||||
$company = $query->append(['province_name', 'city_name', 'area_name', 'street_name', 'area_manager_name'])->toArray();
|
||||
$company['other_contacts'] = json_decode($company['other_contacts'], true);
|
||||
$company['qualification'] = $company['qualification'] != null ? json_decode($company['qualification'], true) : '';
|
||||
$contract = Contract::find($company['contract_id']);
|
||||
@ -67,7 +68,7 @@ class CompanyController extends BaseApiController
|
||||
public function areaManager()
|
||||
{
|
||||
$adminIds = AdminRole::where('role_id', 8)->column('admin_id');
|
||||
$data = Admin::wherein('id', $adminIds)->field('id,name,account,avatar,province,city,area,street')->select()->toArray();
|
||||
$data = Admin::wherein('id', $adminIds)->append(['province_name', 'city_name', 'area_name', 'street_name'])->field('id,name,account,avatar,province,city,area,street')->select()->toArray();
|
||||
return $this->success('success', $data);
|
||||
}
|
||||
|
||||
|
@ -32,4 +32,29 @@ class Company extends BaseModel
|
||||
return DictData::where('id', $value)->value('name');
|
||||
}
|
||||
|
||||
public function getProvinceNameAttr($value)
|
||||
{
|
||||
return Db::name('geo_province')->where(['province_code' => $this->province])->value('province_name');
|
||||
}
|
||||
|
||||
public function getCityNameAttr($value)
|
||||
{
|
||||
return Db::name('geo_city')->where(['city_code' => $this->city])->value('city_name');
|
||||
}
|
||||
|
||||
public function getAreaNameAttr($value)
|
||||
{
|
||||
return Db::name('geo_area')->where(['area_code' => $this->area])->value('area_name');
|
||||
}
|
||||
|
||||
public function getStreetNameAttr($value)
|
||||
{
|
||||
return Db::name('geo_street')->where(['street_code' => $this->street])->value('street_name');
|
||||
}
|
||||
|
||||
public function getAreaManagerNameAttr($value)
|
||||
{
|
||||
return Db::name('admin')->where(['id' => $this->area_manager])->value('name');
|
||||
}
|
||||
|
||||
}
|
@ -120,4 +120,24 @@ class Admin extends BaseModel
|
||||
return $this->hasOne(Company::class, 'id', 'company_id');
|
||||
}
|
||||
|
||||
public function getProvinceNameAttr($value)
|
||||
{
|
||||
return Db::name('geo_province')->where(['province_code' => $this->province])->value('province_name');
|
||||
}
|
||||
|
||||
public function getCityNameAttr($value)
|
||||
{
|
||||
return Db::name('geo_city')->where(['city_code' => $this->city])->value('city_name');
|
||||
}
|
||||
|
||||
public function getAreaNameAttr($value)
|
||||
{
|
||||
return Db::name('geo_area')->where(['area_code' => $this->area])->value('area_name');
|
||||
}
|
||||
|
||||
public function getStreetNameAttr($value)
|
||||
{
|
||||
return Db::name('geo_street')->where(['street_code' => $this->street])->value('street_name');
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user