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

87 lines
2.7 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
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->radio('type')
  47. ->options(AgentType::array())
  48. ->disable();
  49. $this->text('name')->required();
  50. $this->text('company_name')->required()->disable();
  51. $this->text('province.name','省份')->disable();
  52. $this->text('city.name','城市')->disable();
  53. $this->text('area.name','地区')->disable();
  54. $this->text('credit_codes')->required()->disable();
  55. $this->text('address')->required()->disable();
  56. $this->text('director')->required();
  57. $this->text('contact_phone')->required();
  58. $this->image('logo')->required();
  59. $this->image('avatar');
  60. $this->image('license_pic')->required()->disable();
  61. $this->text('legal_persona_name')->required()->disable();
  62. $this->text('legal_persona_wechat')->required();
  63. $this->editor('agentInfo.about')->required();
  64. $this->editor('agentInfo.reg_protocol')->required();
  65. $this->editor('agentInfo.buy_protocol')->required();
  66. $this->confirm('编辑确认', '编辑内容需要管理员重新审核,确定要提交吗?');
  67. }
  68. /**
  69. * The data of the form.
  70. *
  71. * @return array
  72. */
  73. public function default()
  74. {
  75. return Agent::with(['agentInfo','province','city','area'])->find(Admin::user()->id)->toArray();
  76. }
  77. }