1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace App\Http\Controllers\App;
- use App\Http\Controllers\Controller;
- use App\Models\AdminUser;
- use App\Models\AdminUserArea;
- use App\Models\Area;
- use App\Utils\Admin;
- use Illuminate\Support\Facades\Log;
- class AppBaseController extends Controller
- {
- public static $areaIds = [];
- public static $app_type = 'weapp';
- public static $url = 'http://resource.bike.hanyiyun.com';
- /**
- * AppBaseController constructor.
- */
- public function __construct()
- {
- $admin = Admin::user();
- if (empty($admin)) {
- return;
- }
- $type = $admin->type;
- // 判断管理员类型 获取区域
- if ($type == AdminUser::TYPE_WORKER) { // 类型为地勤
- $area_id = Admin::user()->area_id;
- self::$areaIds = [$area_id];
- } else { // 类型为管理员
- $admin_id = Admin::user()->id;
- if (Admin::isAdministrator()) {
- $area_ids = Area::query()->pluck('id')->toArray();
- $area_ids[] = 0;
- self::$areaIds = $area_ids;
- } else {
- $area_ids = AdminUser::getAreaIdsByAdminId($admin_id);
- self::$areaIds = $area_ids;
- }
- }
- if ($type = request()->header('type', false)) {
- self::$app_type = $type;
- self::$url = '/static/img';
- }
- }
- }
|