init project
This commit is contained in:
28
app/Http/Controllers/Helper/GlobalController.php
Normal file
28
app/Http/Controllers/Helper/GlobalController.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Helper;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class GlobalController extends Controller
|
||||
{
|
||||
public static function user_can($role, array $modules) {
|
||||
try{
|
||||
if(Auth::user()->name == 'administrator' && Auth::id()==1) return true;
|
||||
$user_can = DB::table('sys_permissions')
|
||||
->join('sys_role_has_permissions','sys_role_has_permissions.permission_id','sys_permissions.id')
|
||||
->whereIn('sys_permissions.code',$modules)
|
||||
->where('sys_role_has_permissions.role_id', $role)
|
||||
->exists();
|
||||
return $user_can;
|
||||
}
|
||||
catch (\Exception $e){
|
||||
Log::error($e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user