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