Hi, I have installed Laravel 8 for a project, I also use Spatie for managing roles and permissions.
I was wondering how in the event of an error page, which shows the warning, instead redirect the user to the home by showing a simple alert.
I find it unpleasant to show the error on a single page, it would be more appropriate for me to show the error with an alert directly on the home page.
Hi, thanks for your help but sadly that's not what I'm looking for. In the sense, what I would need concerns certain exceptions, such as errors 500, 503, 404, 403, 401 which are shown on a separate page. I would like the message to be shown in home with a redirect instead.
I believe I should act on app/Exceptions/Handler?
But how?
//app/Exceptions/Handler
public function render($request, Throwable $e)
{
if (get_class($e) === \Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class){
return redirect()->to(route('home'))->with('error', 'this is an error');
}
return parent::render($request, $e); // TODO: Change the autogenerated stub
}