Skip to content

Instantly share code, notes, and snippets.

@B-Carcamo
Last active October 20, 2023 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save B-Carcamo/c346be2f1f5c0978e8c04d02e45d320e to your computer and use it in GitHub Desktop.
Save B-Carcamo/c346be2f1f5c0978e8c04d02e45d320e to your computer and use it in GitHub Desktop.
How to change the path from logout(admin/login) to Home (/) in filament 3 - laravel
<?php
//We perform the tasks in the AppServiceProvider file (file in the App/Providers folder) inside the boot function.
use App\Filament\Logout;
use Filament\Http\Responses\Auth\Contracts\LogoutResponse as LogoutResponseContract;
// ...
public function boot()
{
$this->app->bind(LogoutResponseContract::class,Logout::class);
}
/*LogoutResponseContract is the name of the service to be registered
Logout is a function that will be used to create an instance of the service.*/
<?php
//We create a class in the AppFilament folder that implements the LogoutResponse of filament
namespace App\Filament;
use Filament\Http\Responses\Auth\Contracts\LogoutResponse as Responsable;
use Illuminate\Http\RedirectResponse;
class Logout implements Responsable
{
public function toResponse($request): RedirectResponse
{
return redirect()->to(
route('home'), // put the name of your home route here
);
}
}
<?php
//add a name to the root path(/), in this case it will be called home
Route::get('/', function () {
return view('home');
})->name('home');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment