$id = Auth::user()->id;print_r($id);
{{Auth::user()->username}}
$userId = Auth::id();
// Get the currently authenticated user's ID...
$id = Auth::id();
Laravel's laravel/ui package provides a quick way to scaffold all of the routes and views you need for authentication using a few simple commands:
composer require laravel/ui
php artisan ui vue --auth
Auth::user();
use IlluminateSupportFacadesAuth;
// Retrieve the currently authenticated user...
$user = Auth::user();
// Retrieve the currently authenticated user's ID...
$id = Auth::id();
// Only for laravel 6.x and higher
composer require laravel/ui "^1.0" --dev
php artisan ui vue --auth
// Laravel 5.x
php artisan make:auth
composer require laravel/ui:^2.4
php artisan ui vue --auth
use IlluminateSupportFacadesAuth;
Auth::login($user);
Route::get('/flights', function () {
// Only authenticated users may access this route...
})->middleware('auth:admin');