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.
		
		
		
		
		
			
		
			
				
					
					
						
							75 lines
						
					
					
						
							2.0 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							75 lines
						
					
					
						
							2.0 KiB
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								namespace App\AdminAgent\Forms;
							 | 
						|
								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->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->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->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();
							 | 
						|
								
							 | 
						|
										$this->confirm('编辑确认', '编辑内容需要管理员重新审核,确定要提交吗?');
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     * The data of the form.
							 | 
						|
								     *
							 | 
						|
								     * @return array
							 | 
						|
								     */
							 | 
						|
								    public function default()
							 | 
						|
								    {
							 | 
						|
								        return Agent::with('agentInfo')->find(Admin::user()->id)->toArray();
							 | 
						|
								    }
							 | 
						|
								}
							 |