Auth::logout();
$userId = Auth::id();
composer require laravel/ui
php artisan ui vue --auth
npm install && npm run dev
Auth::user();
<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
use IlluminateSupportFacadesAuth;
class LoginController extends Controller
{
/**
* Handle an authentication attempt.
*
* @param IlluminateHttpRequest $request
* @return IlluminateHttpResponse
*/
public function authenticate(Request $request)
{
$credentials = $request->validate([
'email' => ['required', 'email'],
'password' => ['required'],
]);
if (Auth::attempt($credentials)) {
$request->session()->regenerate();
return redirect()->intended('dashboard');
}
return back()->withErrors([
'email' => 'The provided credentials do not match our records.',
]);
}
}
//namespace
use IlluminateSupportFacadesAuth;
use Auth;
//find auth
function __construct()
{
$this->middleware('auth');
}
//end find auth
Route::get('/flights', function () {
// Only authenticated users may access this route...
})->middleware('auth:admin');