海南旅游SAAS
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.

71 lines
1.9 KiB

  1. <?php
  2. namespace App\AdminAgent\Forms;
  3. use App\Models\Agent;
  4. use Dcat\Admin\Admin;
  5. use Dcat\Admin\Widgets\Form;
  6. class AgentInfo extends Form
  7. {
  8. /**
  9. * Handle the form request.
  10. *
  11. * @param array $input
  12. *
  13. * @return mixed
  14. */
  15. public function handle(array $input)
  16. {
  17. // dump($input);
  18. $model = Agent::query()->find(Admin::user()->id);
  19. $model->name = $input['name'];
  20. $model->company_name = $input['company_name'];
  21. $model->address = $input['address'];
  22. $model->director = $input['director'];
  23. $model->contact_phone = $input['contact_phone'];
  24. $model->logo = $input['logo'];
  25. $model->avatar = $input['avatar'];
  26. $model->license_pic = $input['license_pic'];
  27. $model->agentInfo->about = $input['agentInfo']['about'];
  28. $model->agentInfo->reg_protocol = $input['agentInfo']['reg_protocol'];
  29. $model->agentInfo->buy_protocol = $input['agentInfo']['buy_protocol'];
  30. $model->save();
  31. $model->agentInfo()->save($model->agentInfo);
  32. return $this->response()->success('保存成功')->refresh();
  33. }
  34. /**
  35. * Build a form here.
  36. */
  37. public function form()
  38. {
  39. Admin::translation('agent');
  40. $this->text('name')->required();
  41. $this->text('company_name')->required();
  42. $this->text('address')->required();
  43. $this->text('director')->required();
  44. $this->text('contact_phone')->required();
  45. $this->image('logo')->required();
  46. $this->image('avatar');
  47. $this->image('license_pic')->required();
  48. $this->editor('agentInfo.about')->required();
  49. $this->editor('agentInfo.reg_protocol')->required();
  50. $this->editor('agentInfo.buy_protocol')->required();
  51. }
  52. /**
  53. * The data of the form.
  54. *
  55. * @return array
  56. */
  57. public function default()
  58. {
  59. return Agent::with('agentInfo')->find(Admin::user()->id)->toArray();
  60. }
  61. }