if (Auth::check()) { // User is logged in } else { // User is not logged in }
$user = Auth::user(); if ($user) { // Do something with the authenticated user } else { // User is not logged in }
if (Auth::user()->hasRole('admin')) { // User is an admin } else { // User is not an admin }In all the above examples, the Auth facade is used to interact with the authentication system provided by the Laravel framework.