12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace App\Utils;
- class Admin
- {
- const ROLE_JISHU_ADMIN = 'administrator';
- const ROLE_MERCHANT = 'merchantsAdmin';
- const ROLE_ADMIN = 'normalAdministrator';
- const ROLE_AREA_ADMIN = 'areaAdmin';
- const ROLE_CUSTOMER = 'customerService';
- /**
- * 当前登录管理员
- *
- * @return \App\Models\AdminUser|\Illuminate\Contracts\Auth\Authenticatable
- */
- public static function user()
- {
- return static::guard()->user();
- }
- /**
- * 当前登录管理员是不是超级管理员
- *
- * @return bool
- */
- public static function isAdministrator()
- {
- return static::user() && static::user()->isAdministrator();
- }
- /**
- * 当前登录管理员是不是普通超级管理员
- *
- * @return bool
- */
- public static function isNormalAdministrator()
- {
- return static::user() && static::user()->isNormalAdministrator();
- }
- /**
- * 判断当前管理员是否是区域管理员
- *
- * @return
- * */
- public static function isAreaAdmin()
- {
- return static::user() && static::user()->isAreaAdmin();
- }
- /**
- * 是否为商户
- * @return bool
- * Author: Mead
- */
- public static function isMerchantAdmin()
- {
- return static::user() && static::user()->isMerchantAdmin();
- }
- /**
- * 把路径自动拼上后端的路径前缀
- *
- * @param string $path
- *
- * @return string
- */
- public static function url($path = '')
- {
- $prefix = 'admin-api';
- $path = trim($path, '/');
- if (is_null($path) || strlen($path) == 0) {
- $path = $prefix;
- } else {
- $path = $prefix . '/' . $path;
- }
- return $path;
- }
- /**
- * @return \Illuminate\Contracts\Auth\Guard|\Tymon\JWTAuth\JWTGuard
- */
- public static function guard()
- {
- return auth('admin');
- }
- }
|