From 3e50fd191254688f3dcc7e12ca050b6746d5236b Mon Sep 17 00:00:00 2001 From: lemon <15040771@qq.com> Date: Sun, 26 Sep 2021 15:55:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AdminAgent/Forms/AgentInfo.php | 16 +++++++++------- app/AdminSupplier/Forms/SupplierInfo.php | 14 ++++++++------ app/Models/Agent.php | 15 +++++++++++++++ app/Models/ChinaArea.php | 15 +++++++++++++++ app/Models/Supplier.php | 15 +++++++++++++++ 5 files changed, 62 insertions(+), 13 deletions(-) create mode 100755 app/Models/ChinaArea.php diff --git a/app/AdminAgent/Forms/AgentInfo.php b/app/AdminAgent/Forms/AgentInfo.php index 2dc6780..a5fc85e 100644 --- a/app/AdminAgent/Forms/AgentInfo.php +++ b/app/AdminAgent/Forms/AgentInfo.php @@ -23,15 +23,15 @@ class AgentInfo extends Form $model = Agent::query()->find(Admin::user()->id); $model->name = $input['name']; - $model->company_name = $input['company_name']; - $model->credit_codes = $input['credit_codes']; - $model->address = $input['address']; + //$model->company_name = $input['company_name']; + //$model->credit_codes = $input['credit_codes']; + //$model->address = $input['address']; $model->director = $input['director']; $model->contact_phone = $input['contact_phone']; $model->logo = $input['logo']; $model->avatar = $input['avatar']; - $model->license_pic = $input['license_pic']; - $model->legal_persona_name = $input['legal_persona_name']; + //$model->license_pic = $input['license_pic']; + //$model->legal_persona_name = $input['legal_persona_name']; $model->legal_persona_wechat = $input['legal_persona_wechat']; $model->status = UserStatus::UNAUDITED; @@ -52,10 +52,12 @@ class AgentInfo extends Form Admin::translation('agent'); $this->radio('type') ->options(AgentType::array()) - ->required() ->disable(); $this->text('name')->required(); $this->text('company_name')->required()->disable(); + $this->text('province.name','省份')->disable(); + $this->text('city.name','城市')->disable(); + $this->text('area.name','地区')->disable(); $this->text('credit_codes')->required()->disable(); $this->text('address')->required()->disable(); $this->text('director')->required(); @@ -80,6 +82,6 @@ class AgentInfo extends Form */ public function default() { - return Agent::with('agentInfo')->find(Admin::user()->id)->toArray(); + return Agent::with(['agentInfo','province','city','area'])->find(Admin::user()->id)->toArray(); } } diff --git a/app/AdminSupplier/Forms/SupplierInfo.php b/app/AdminSupplier/Forms/SupplierInfo.php index 1a7ecfd..89bc8a5 100644 --- a/app/AdminSupplier/Forms/SupplierInfo.php +++ b/app/AdminSupplier/Forms/SupplierInfo.php @@ -21,15 +21,14 @@ class SupplierInfo extends Form // dump($input); $model = Supplier::find(Admin::user()->id); - $model->name = $input['name']; - $model->company_name = $input['company_name']; - $model->address = $input['address']; + //$model->company_name = $input['company_name']; + //$model->address = $input['address']; $model->director = $input['director']; $model->contact_phone = $input['contact_phone']; $model->avatar = $input['avatar']; $model->logo = $input['logo']; - $model->license_pic = $input['license_pic']; + //$model->license_pic = $input['license_pic']; $model->status = UserStatus::UNAUDITED; $model->save(); @@ -44,7 +43,10 @@ class SupplierInfo extends Form Admin::translation('supplier'); $this->text('name')->required(); - $this->text('company_name')->required()->disable(); + $this->text('company_name')->disable(); + $this->text('province.name','省份')->disable(); + $this->text('city.name','城市')->disable(); + $this->text('area.name','地区')->disable(); $this->text('address')->required()->disable(); $this->text('director')->required(); $this->text('contact_phone')->required(); @@ -62,6 +64,6 @@ class SupplierInfo extends Form */ public function default() { - return Supplier::find(Admin::user()->id)->toArray(); + return Supplier::with(['province','city','area'])->find(Admin::user()->id)->toArray(); } } diff --git a/app/Models/Agent.php b/app/Models/Agent.php index 0756652..ca20d5d 100644 --- a/app/Models/Agent.php +++ b/app/Models/Agent.php @@ -69,4 +69,19 @@ class Agent extends BaseModel { return $this->morphOne('App\Models\Withdrawal', 'user'); } + + public function province() + { + return $this->belongsTo('App\Models\ChinaArea', 'province_id','code'); + } + + public function city() + { + return $this->belongsTo('App\Models\ChinaArea', 'city_id','code'); + } + + public function area() + { + return $this->belongsTo('App\Models\ChinaArea', 'area_id','code'); + } } diff --git a/app/Models/ChinaArea.php b/app/Models/ChinaArea.php new file mode 100755 index 0000000..9117000 --- /dev/null +++ b/app/Models/ChinaArea.php @@ -0,0 +1,15 @@ +morphOne('App\Models\Withdrawal', 'user'); } + + public function province() + { + return $this->belongsTo('App\Models\ChinaArea', 'province_id','code'); + } + + public function city() + { + return $this->belongsTo('App\Models\ChinaArea', 'city_id','code'); + } + + public function area() + { + return $this->belongsTo('App\Models\ChinaArea', 'area_id','code'); + } }