Support the ongoing development of Laravel.io →
Authentication Eloquent
Last updated 1 year ago.
0

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.');
        }
    }
});
Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

wanted80 wanted80 Joined 22 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.