Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Dec 4, 2024
1 parent 67463fe commit c3e29e1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Http/Requests/FrontendFormRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,15 @@ public function validateResolved()
// If this was submitted from a front-end form, we want to use the appropriate language
// for the translation messages. If there's no previous url, it was likely submitted
// directly in a headless format. In that case, we'll just use the default lang.
$site = ($previousUrl = session()->previousUrl()) ? Site::findByUrl($previousUrl) : null;
$site = ($previousUrl = $this->previousUrl()) ? Site::findByUrl($previousUrl) : null;

return $this->withLocale($site?->lang(), fn () => parent::validateResolved());
}

private function previousUrl()
{
return ($referrer = request()->header('referer'))
? url()->to($referrer)
: session()->previousUrl();
}
}

0 comments on commit c3e29e1

Please sign in to comment.