So instead the next best option is resolving an anonymous class that proxies the inertia response
$this->app->singleton(LoginViewResponse::class, function () {
return new class implements LoginViewResponse
{
public function toResponse($request)
{
return Inertia::render('Login')->toResponse($request);
}
};
});
This works perfectly but isn't exactly friendly.
My suggestion is that we loosen the typehint to just Response and allow Fortify::loginView to take a closure which would be used as the binding, meaning it would be as simple as
Right now if we want to change the login view we can do
But that only allows you to change it to a different view name, behind the scenes it's just rendering a singleton binding for
LoginViewResponse
.You'd think no stress, we can override that binding for example for an Inertia view
But unfortunately this doesn't work due to the typehint on the controller method
So instead the next best option is resolving an anonymous class that proxies the inertia response
This works perfectly but isn't exactly friendly. My suggestion is that we loosen the typehint to just
Response
and allowFortify::loginView
to take a closure which would be used as the binding, meaning it would be as simple asOf course we'd do the same for the other view methods. I'm happy to PR this if the idea gets approved.