Redirect customer to home page after they login or logout
I have three panels in my app: Admin, Vendor and Customer(default). All three panels use filament's authentication features. In the customer's panel provider, I have added the path to be empty:
$panel->path(' '). I want when a customer logs in to the system through Filament's login page, they should be redirected to the homepage and not the panel's dashboard. The customers can still visit the filament dashboard through the /dashboard. How can I achieve this functionality? Has anyone tried something similar before?Solution
<?php
namespace App\Filament;
use Filament\Http\Responses\Auth\Contracts\LogoutResponse as Responsable;
use Illuminate\Http\RedirectResponse;
class MyLogoutResponse implements Responsable
{
public function toResponse($request): RedirectResponse
{
return redirect()->to(
route('home'), // put the name of your home route here
);
}
}
namespace App\Filament;
use Filament\Http\Responses\Auth\Contracts\LogoutResponse as Responsable;
use Illuminate\Http\RedirectResponse;
class MyLogoutResponse implements Responsable
{
public function toResponse($request): RedirectResponse
{
return redirect()->to(
route('home'), // put the name of your home route here
);
}
}