Controller.php 1.1 KB

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