I'm looking for a fix to allow a redirect in a sub-function call, instead of in a controller
I've created the following function & call and it works, with the redirect in the controller instead of my sub function call.
Here is my call to the function checkAccess():
$access = new \App\Library\Access;
if($access->checkAccess($accessList, 'admin-dashboard', 'r')){
return view('portal.admin.dashboard');
}else{
return redirect('/');
}
Here is my function:
public function checkAccess($accessList, $element, $permission){
if(is_array($accessList)){
foreach($accessList as $access){
if($access->element == $element && $access->permission == $permission){
return true;
}
}
}
return false;
}
I have tried replacing the return false; with the redirect and this does not work. It basically just returns true.
And icing on the cake if you know a better way of checking if an object list has parameters w/o having to do a foreach like I am that'd be pretty amazing!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire