You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							87 lines
						
					
					
						
							2.7 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							87 lines
						
					
					
						
							2.7 KiB
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								namespace App\AdminAgent\Forms;
							 | 
						|
								use App\Common\AgentType;
							 | 
						|
								use App\Common\UserStatus;
							 | 
						|
								use App\Models\Agent;
							 | 
						|
								use Dcat\Admin\Admin;
							 | 
						|
								use Dcat\Admin\Widgets\Form;
							 | 
						|
								
							 | 
						|
								class AgentInfo extends Form
							 | 
						|
								{
							 | 
						|
								    /**
							 | 
						|
								     * Handle the form request.
							 | 
						|
								     *
							 | 
						|
								     * @param array $input
							 | 
						|
								     *
							 | 
						|
								     * @return mixed
							 | 
						|
								     */
							 | 
						|
								    public function handle(array $input)
							 | 
						|
								    {
							 | 
						|
								        // dump($input);
							 | 
						|
								
							 | 
						|
								        $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->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->legal_persona_wechat = $input['legal_persona_wechat'];
							 | 
						|
										$model->status = UserStatus::UNAUDITED;
							 | 
						|
								
							 | 
						|
										$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->agentInfo()->save($model->agentInfo);
							 | 
						|
								
							 | 
						|
								        return $this->response()->success('保存成功')->refresh();
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     * Build a form here.
							 | 
						|
								     */
							 | 
						|
								    public function form()
							 | 
						|
								    {
							 | 
						|
								    	Admin::translation('agent');
							 | 
						|
										$this->radio('type')
							 | 
						|
											->options(AgentType::array())
							 | 
						|
											->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();
							 | 
						|
										$this->text('contact_phone')->required();
							 | 
						|
										$this->image('logo')->required();
							 | 
						|
										$this->image('avatar');
							 | 
						|
										$this->image('license_pic')->required()->disable();
							 | 
						|
										$this->text('legal_persona_name')->required()->disable();
							 | 
						|
										$this->text('legal_persona_wechat')->required();
							 | 
						|
								
							 | 
						|
								        $this->editor('agentInfo.about')->required();
							 | 
						|
								        $this->editor('agentInfo.reg_protocol')->required();
							 | 
						|
								        $this->editor('agentInfo.buy_protocol')->required();
							 | 
						|
								
							 | 
						|
										$this->confirm('编辑确认', '编辑内容需要管理员重新审核,确定要提交吗?');
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     * The data of the form.
							 | 
						|
								     *
							 | 
						|
								     * @return array
							 | 
						|
								     */
							 | 
						|
								    public function default()
							 | 
						|
								    {
							 | 
						|
								        return Agent::with(['agentInfo','province','city','area'])->find(Admin::user()->id)->toArray();
							 | 
						|
								    }
							 | 
						|
								}
							 |