Controller.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Dingo\Api\Routing\Helpers;
  4. use Laravel\Lumen\Routing\Controller as BaseController;
  5. class Controller extends BaseController
  6. {
  7. use Helpers;
  8. // 返回错误的请求
  9. protected function errorBadRequest($msg)
  10. {
  11. $this->response->errorBadRequest($msg);
  12. }
  13. /**
  14. * 验证错误
  15. * @param $msg
  16. * User: Mead
  17. */
  18. protected function errorNoValidation($msg, $code = 422)
  19. {
  20. $this->response->error($msg, $code);
  21. }
  22. /**
  23. * 验证错误
  24. * @param $msg
  25. * User: Mead
  26. */
  27. protected function errorNoYundong($msg)
  28. {
  29. $this->response->error($msg, 450);
  30. }
  31. /**
  32. * 异常错误
  33. * @param $msg
  34. * User: Mead
  35. */
  36. protected function errorException($msg)
  37. {
  38. $this->response->error($msg, 423);
  39. }
  40. /**
  41. * 获取当前登录的用户的openid
  42. * @return mixed
  43. * User: Mead
  44. */
  45. protected function getOpenId()
  46. {
  47. return $this->user->auth->credential;
  48. }
  49. }