AppBaseController.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. public static $url = 'http://resource.bike.hanyiyun.com';
  14. /**
  15. * AppBaseController constructor.
  16. */
  17. public function __construct()
  18. {
  19. $admin = Admin::user();
  20. if (empty($admin)) {
  21. return;
  22. }
  23. $type = $admin->type;
  24. // 判断管理员类型 获取区域
  25. if ($type == AdminUser::TYPE_WORKER) { // 类型为地勤
  26. $area_id = Admin::user()->area_id;
  27. self::$areaIds = [$area_id];
  28. } else { // 类型为管理员
  29. $admin_id = Admin::user()->id;
  30. if (Admin::isAdministrator()) {
  31. $area_ids = Area::query()->pluck('id')->toArray();
  32. $area_ids[] = 0;
  33. self::$areaIds = $area_ids;
  34. } else {
  35. $area_ids = AdminUser::getAreaIdsByAdminId($admin_id);
  36. self::$areaIds = $area_ids;
  37. }
  38. }
  39. if ($type = request()->header('type', false)) {
  40. self::$app_type = $type;
  41. self::$url = '/static/img';
  42. }
  43. }
  44. }