I have an application with many user roles. Like Admin
, Manager
etc.
There are some instances where both Manager
and Admin
has the same permission to see/edit a page.
In the route.php
I created a filter group for Admin access only.
//filter.php
Route::filter('admin', function()
{
if (Auth::guest() or ! Auth::user()->isAdmin()) {
return 'Not Authorized';
}
});
//route.php
Route::group(['before' => 'admin'], function(){
//Some routes.....
});
Now, I want to check if the user is allowed to view that page by checking the userId
and the courseId
. How can I get these values in the filter.php
?
I have a function which checks if the user is authorized for that page. But it requires two variables to be passed (Atleast one variable, the courseId
)
public static function isAllowed($userId, $courseId){
//Some conditions.
}
How can I do this?