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

81 lines
2.4 KiB

4 years ago
4 years ago
4 years ago
4 years ago
  1. <?php
  2. namespace App\AdminAgent\Forms;
  3. use App\Common\UserStatus;
  4. use App\Models\Agent;
  5. use Dcat\Admin\Admin;
  6. use Dcat\Admin\Widgets\Form;
  7. class AgentInfo extends Form
  8. {
  9. /**
  10. * Handle the form request.
  11. *
  12. * @param array $input
  13. *
  14. * @return mixed
  15. */
  16. public function handle(array $input)
  17. {
  18. // dump($input);
  19. $model = Agent::query()->find(Admin::user()->id);
  20. $model->name = $input['name'];
  21. $model->company_name = $input['company_name'];
  22. $model->credit_codes = $input['credit_codes'];
  23. $model->address = $input['address'];
  24. $model->director = $input['director'];
  25. $model->contact_phone = $input['contact_phone'];
  26. $model->logo = $input['logo'];
  27. $model->avatar = $input['avatar'];
  28. $model->license_pic = $input['license_pic'];
  29. $model->legal_persona_name = $input['legal_persona_name'];
  30. $model->legal_persona_wechat = $input['legal_persona_wechat'];
  31. $model->status = UserStatus::UNAUDITED;
  32. $model->agentInfo->about = $input['agentInfo']['about'];
  33. $model->agentInfo->reg_protocol = $input['agentInfo']['reg_protocol'];
  34. $model->agentInfo->buy_protocol = $input['agentInfo']['buy_protocol'];
  35. $model->save();
  36. $model->agentInfo()->save($model->agentInfo);
  37. return $this->response()->success('保存成功')->refresh();
  38. }
  39. /**
  40. * Build a form here.
  41. */
  42. public function form()
  43. {
  44. Admin::translation('agent');
  45. $this->text('name')->required();
  46. $this->text('company_name')->required();
  47. $this->text('credit_codes')->required();
  48. $this->text('address')->required();
  49. $this->text('director')->required();
  50. $this->text('contact_phone')->required();
  51. $this->image('logo')->required();
  52. $this->image('avatar');
  53. $this->image('license_pic')->required();
  54. $this->text('legal_persona_name')->required();
  55. $this->text('legal_persona_wechat')->required();
  56. $this->editor('agentInfo.about')->required();
  57. $this->editor('agentInfo.reg_protocol')->required();
  58. $this->editor('agentInfo.buy_protocol')->required();
  59. $this->confirm('编辑确认', '编辑内容需要管理员重新审核,确定要提交吗?');
  60. }
  61. /**
  62. * The data of the form.
  63. *
  64. * @return array
  65. */
  66. public function default()
  67. {
  68. return Agent::with('agentInfo')->find(Admin::user()->id)->toArray();
  69. }
  70. }