Last active
October 20, 2023 04:26
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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.*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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