vendredi 5 mai 2017

How to check if Session::has('loggedOn') and call a controller in a view?

I am new to laravel and can't manage to to check whether the user is logged on or not, before accessing page trough URL directly.

I suppose the check should be done in the routes and there is no problem to do so when calling a view from the route:

Route::get('/', function()
    {
    if (!Session::has('loggedOn'))
        {
        return view('viewLogin');
        }
    else
        {
        return view('viewAllData');
        }
    });
    enter code here

But when I want to call a Controller and check if (!Session::has('loggedOn')), how is this done?

Route::get('/messagesPage', 'MsgsController@messages');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire