Apply.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace addons\ddrive\controller;
  3. use app\common\controller\Api;
  4. /**
  5. * 申请代驾接口
  6. */
  7. class Apply extends Api
  8. {
  9. protected $noNeedLogin = [];
  10. protected $noNeedRight = ['*'];
  11. public function _initialize()
  12. {
  13. parent::_initialize();
  14. $this->model = new \addons\ddrive\model\Apply;
  15. }
  16. /**
  17. * 代驾申请
  18. *
  19. * @return void
  20. */
  21. public function add()
  22. {
  23. $data = [
  24. 'name' => $this->request->post('name'),
  25. 'image' => $this->request->post('image'),
  26. 'mobile' => $this->request->post('mobile'),
  27. 'driving_age' => $this->request->post('driving_age'),
  28. 'card_id' => $this->request->post('card_id'),
  29. 'card_image' => $this->request->post('card_image'),
  30. 'card_back_image' => $this->request->post('card_back_image'),
  31. 'driver_image' => $this->request->post('driver_image'),
  32. 'user_id' => $this->auth->id,
  33. ];
  34. if ($this->request->post('id')) {
  35. $data['status'] = 0;
  36. $res = $this->model->where('id', $this->request->post('id'))->update($data);
  37. } else {
  38. $res = $this->model->data($data)->save();
  39. }
  40. if ($res) {
  41. $this->success('申请成功,请等待审核');
  42. } else {
  43. if ($this->request->post('id')) {
  44. $this->error('申请失败,请检查信息是否修改');
  45. } else {
  46. $this->error('申请失败,请检查信息是否填写正确');
  47. }
  48. }
  49. }
  50. /**
  51. * 获取详情
  52. *
  53. * @return void
  54. */
  55. public function info()
  56. {
  57. $info = $this->model->where('user_id', $this->auth->id)->find();
  58. $this->success('', $info);
  59. }
  60. }