Laravel 5 check whether a user is logged in Laravel 5 check whether a user is logged in laravel laravel

Laravel 5 check whether a user is logged in


You should use the auth middleware. In your route just add it like this:

Route::get('pages/mainpage', ['middleware' => 'auth', 'uses' => 'FooController@index']);

Or in your controllers constructor:

public function __construct(){    $this->middleware('auth');}


you can do this directly in your blade code by this way

@if (!Auth::guest())        do this @else        do that@endif