laravel user must login before accessing a view code example
Example 1: laravel auth
//namespace
use Illuminate\Support\Facades\Auth;
Example 2: laravel force login by id
Auth::login($user);
//namespace
use Illuminate\Support\Facades\Auth;
Auth::login($user);