Ok...I solved it by myself XD
public function getIsRole($role)
{
return $this->role->name === $role;
}
public function isAdmin()
{
return $this->getIsRole('admin');
}
Route::filter('auth.admin', function()
{
if (Auth::guest()) {
return Redirect::guest('/user/login');
} else {
if (!Auth::user()->isAdmin()) {
App::abort(401, 'Unauthorized access to a restricted area.');
}
}
});
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community