Browse Source

地区

master
lemon 4 years ago
parent
commit
3e50fd1912
  1. 16
      app/AdminAgent/Forms/AgentInfo.php
  2. 14
      app/AdminSupplier/Forms/SupplierInfo.php
  3. 15
      app/Models/Agent.php
  4. 15
      app/Models/ChinaArea.php
  5. 15
      app/Models/Supplier.php

16
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();
}
}

14
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();
}
}

15
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');
}
}

15
app/Models/ChinaArea.php

@ -0,0 +1,15 @@
<?php
namespace App\Models;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
class ChinaArea extends Model
{
use HasDateTimeFormatter;
protected $table = 'china_area';
public $timestamps = false;
}

15
app/Models/Supplier.php

@ -69,4 +69,19 @@ class Supplier 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');
}
}
Loading…
Cancel
Save