Meandering Soul

This day is done, I'm going home.
eFranes Penguin Avatar

Redirecting in Laravel Form Requests

08
May 2015

While Form Request Validation in Laravel 5 usually does exactly what it’s supposed to do, I recently had to append a location hash to the redirect URL. Turns out that’s as simple as overwriting the FormRequest’s getRedirectUrl()-method:

1
2
3
4
5
protected function getRedirectUrl()
{
  $url = $this->redirector->getUrlGenerator();
  return $url->previous().'#hash';
}
  • Published on May 08, 2015
  • 49 words