AppBaseController.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace App\Http\Controllers\App;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\AdminUser;
  5. use App\Models\AdminUserArea;
  6. use App\Models\Area;
  7. use App\Utils\Admin;
  8. use Illuminate\Support\Facades\Log;
  9. class AppBaseController extends Controller
  10. {
  11. public static $areaIds = [];
  12. public static $app_type = 'weapp';
  13. const WEAPP = 'weapp';
  14. const APP = 'app';
  15. public static $url = 'http://resource.bike.hanyiyun.com';
  16. /**
  17. * AppBaseController constructor.
  18. */
  19. public function __construct()
  20. {
  21. $admin = Admin::user();
  22. if (empty($admin)) {
  23. return;
  24. }
  25. $type = $admin->type;
  26. // 判断管理员类型 获取区域
  27. if ($type == AdminUser::TYPE_WORKER) { // 类型为地勤
  28. $area_id = Admin::user()->area_id;
  29. self::$areaIds = [$area_id];
  30. } else { // 类型为管理员
  31. $admin_id = Admin::user()->id;
  32. if (Admin::isAdministrator()) {
  33. $area_ids = Area::query()->pluck('id')->toArray();
  34. $area_ids[] = 0;
  35. self::$areaIds = $area_ids;
  36. } else {
  37. $area_ids = AdminUser::getAreaIdsByAdminId($admin_id);
  38. self::$areaIds = $area_ids;
  39. }
  40. }
  41. if ($type = request()->header('type', false)) {
  42. self::$app_type = $type;
  43. self::$url = '/static/img';
  44. }
  45. }
  46. }