diff --git a/app/Models/CommonModel.php b/app/Models/CommonModel.php index 8c945f5..11f2281 100755 --- a/app/Models/CommonModel.php +++ b/app/Models/CommonModel.php @@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; use OwenIt\Auditing\Contracts\Auditable; +use Spatie\Permission\Models\Role; class CommonModel extends Model { @@ -132,4 +133,19 @@ class CommonModel extends Model $router->post("{$prefix}/update/{id?}", "{$controller}@update"); $router->post("{$prefix}/delete", "{$controller}@delete"); } + + /** + * 判断是否有导出权限 + */ + public static function checkExport() + { + $userId = auth()->id(); + $roleId = Role::where('name', 'like', '%导出%')->where('guard_name', 'admin')->value('id'); + return DB::table('model_has_roles') + ->where('role_id', $roleId) + ->where('model_type', 'App\Admin') + ->where('model_id', $userId) + ->count(); + } + } diff --git a/resources/views/admin/orders/index.blade.php b/resources/views/admin/orders/index.blade.php index 1c1bb45..409e907 100755 --- a/resources/views/admin/orders/index.blade.php +++ b/resources/views/admin/orders/index.blade.php @@ -37,8 +37,9 @@ - + @if(\App\Models\CommonModel::checkExport()) + @endif