Browse Source

代理商个人信息编辑添加更多字段

dev
李可松 4 years ago
parent
commit
da7161cc0c
  1. 40
      app/AdminAgent/Forms/AgentInfo.php
  2. 1
      resources/lang/zh_CN/agent.php

40
app/AdminAgent/Forms/AgentInfo.php

@ -1,7 +1,7 @@
<?php <?php
namespace App\AdminAgent\Forms; namespace App\AdminAgent\Forms;
use App\Models\AgentInfo as Model;
use App\Models\Agent;
use Dcat\Admin\Admin; use Dcat\Admin\Admin;
use Dcat\Admin\Widgets\Form; use Dcat\Admin\Widgets\Form;
@ -18,11 +18,22 @@ class AgentInfo extends Form
{ {
// dump($input); // dump($input);
$model = Model::query()->find(Admin::user()->id);
$model->about = $input['about'];
$model->reg_protocol = $input['reg_protocol'];
$model->buy_protocol = $input['buy_protocol'];
$model = Agent::query()->find(Admin::user()->id);
$model->name = $input['name'];
$model->company_name = $input['company_name'];
$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->agentInfo->about = $input['agentInfo']['about'];
$model->agentInfo->reg_protocol = $input['agentInfo']['reg_protocol'];
$model->agentInfo->buy_protocol = $input['agentInfo']['buy_protocol'];
$model->save(); $model->save();
$model->agentInfo()->save($model->agentInfo);
return $this->response()->success('保存成功')->refresh(); return $this->response()->success('保存成功')->refresh();
} }
@ -32,9 +43,20 @@ class AgentInfo extends Form
*/ */
public function form() public function form()
{ {
$this->editor('about')->required();
$this->editor('reg_protocol')->required();
$this->editor('buy_protocol')->required();
Admin::translation('agent');
$this->text('name')->required();
$this->text('company_name')->required();
$this->text('address')->required();
$this->text('director')->required();
$this->text('contact_phone')->required();
$this->image('logo')->required();
$this->image('avatar');
$this->image('license_pic')->required();
$this->editor('agentInfo.about')->required();
$this->editor('agentInfo.reg_protocol')->required();
$this->editor('agentInfo.buy_protocol')->required();
} }
/** /**
@ -44,6 +66,6 @@ class AgentInfo extends Form
*/ */
public function default() public function default()
{ {
return Model::query()->find(Admin::user()->id)->toArray();
return Agent::with('agentInfo')->find(Admin::user()->id)->toArray();
} }
} }

1
resources/lang/zh_CN/agent.php

@ -21,6 +21,7 @@ return [
'license_pic' => '营业执照', 'license_pic' => '营业执照',
'director' => '负责人', 'director' => '负责人',
'contact_phone' => '联系电话', 'contact_phone' => '联系电话',
'agentInfo' => trans('agent-info.fields'),
], ],
'options' => [ 'options' => [
], ],

Loading…
Cancel
Save