I'm developing a Laravel ACL System. I have a User table, a role table and a permissions table. When I check the user given permissions using middleware and inside middleware I'm use explode()
function. this function only show the first permissions other permissions doesn't contains.
Here, is my Controller;
function __construct()
{
$this->middleware('auth');
$this->middleware('HasPermission:Role-Read,Role-Update,Role-Delete');
}
My Middleware.
public function handle($request, Closure $next,$permissions='')
{
$permissions_array = explode(',', $permissions);
dd($permissions_array);
foreach($permissions_array as $permission){
if(Auth::user()->hasPermission($permission)){
return $next($request);
}
}
return redirect()->back();;
}
result when i use dd()
function.
array:1 [▼
0 => "Role-Read"
]