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

46 lines
1.2 KiB

4 years ago
4 years ago
4 years ago
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Support\Facades\Cache;
  4. use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
  5. use Illuminate\Foundation\Bus\DispatchesJobs;
  6. use Illuminate\Foundation\Validation\ValidatesRequests;
  7. use Illuminate\Routing\Controller as BaseController;
  8. class Controller extends BaseController
  9. {
  10. use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
  11. protected $user_id = 0;
  12. protected $agent_id = 0; //代理商ID
  13. public function __construct()
  14. {
  15. // TODO 登录部分待优化
  16. $auth = request()->header('Authentication');
  17. $appid = request()->header('appid');
  18. $this->user_id = Cache::get($auth);
  19. $this->agent_id = Cache::get($appid);
  20. }
  21. protected function success($data = [], $msg = 'success', $code = 1, $status = 200): array
  22. {
  23. return [
  24. 'code' => $code,
  25. 'msg' => $msg,
  26. 'data' => $data,
  27. 'status' => $status,
  28. ];
  29. }
  30. protected function error($msg = 'error', $code = -1, $status = 500): array
  31. {
  32. return [
  33. 'code' => $code,
  34. 'msg' => $msg,
  35. 'data' => [],
  36. 'status' => $status,
  37. ];
  38. }
  39. }