1) File : App\Http\Middleware\UserAccess.php Code : $pid = Permission::where('name', $current_location['controller']) ->if($prefixName, 'methods_in', '=', $prefixName)->value('id'); ================================================================================== Reason : ->if() scope not found! ================================================================================== Solution : $pid = Permission::where('name', $current_location['controller']) ->when($prefixName,function($query)use($prefixName){ $query->where('methods_in', $prefixName); })->value('id'); 2) Can't access Auth::user() or seesion inside controllers __construct method because constructor created before middleware attempts. Solution : $this->middleware(function ($request, $next) { /*Put the code here*/ return $next($request); });