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

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