mardi 22 septembre 2015

Laravel 4.2 filter - "Trying to get property of non-object" Error

I am trying to create a filter in Laravel so that only admins are allowed to access some URLs.

What I have done is,

    Route::filter('admin', function()
    {
        if (Auth::user()->permission != -1)
        {
            if (Request::ajax())
            {
                return Response::make('Unauthorized', 401);
            }
            else
            {
                return Redirect::guest('/');
            }
        }
    });

in the app/filters.php file.

But I am getting an eror like this if I try yo access admin's url-

http://ift.tt/1KygTpd

Users table is like this-

http://ift.tt/1L406kC

Can anyone help please?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire