Tricks

Customize redirect after admin panel login

Jun 5, 2022
David VINCENT
Admin panel

Create a LoginResponse class in App\Http\Responses namespace.

The content of the class should be :

<?php
 
namespace App\Http\Responses;
 
use Filament\Http\Responses\Auth\Contracts\LoginResponse as LoginResponseContract;
 
class LoginResponse implements LoginResponseContract
{
/**
* Create an HTTP response that represents the object.
*
* @param \Illuminate\Http\Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function toResponse($request)
{
// return whatever you want as url
$url = 'blabla';
 
return redirect()->intended($url);
}
}
avatar

then add in your service provider.

use Filament\Http\Responses\Auth\Contracts\LoginResponse as LoginResponseContract;
// ....
$this->app->bind(LoginResponseContract::class, \App\Http\Responses\LoginResponse::class);