Courses

Vue Inertia + Laravel 11: From Scratch

Logout and Link with POST Method

Summary of this lesson:
- Adding a logout route in Laravel
- Creating a logout method in LoginController
- Using Inertia Link component with POST method for logout
- Implementing client-side logout functionality

In this lesson, let's work on the logout functionality. I will show you how to use Inertia to make a link, but with post method.


To perform the logout, first on the back-end, let's create the route.

routes/web.php:

Route::view('/', 'dashboard')->name('dashboard');
 
Route::middleware('auth')->group(function () {
Route::resource('posts', PostController::class);
Route::inertia('about', 'About')->name('about');
});
Route::inertia('login', 'Auth/Login')->name('login');
Route::post('login', [\App\Http\Controllers\Auth\LoginController::class, 'store'])->name('login.post');
Route::post('logout', [\App\Http\Controllers\Auth\LoginController::class, 'destroy'])->name('logout');

In the Controller, we will use...

The full lesson is only for Premium Members.
Want to access all 18 lessons of this course? (56 min read)

You also get:

  • 69 courses (majority in latest Laravel 11)
  • Premium tutorials
  • Access to repositories
  • Private Discord