January 1, 2021
In Laravel, you can get the current URL by running url()->current()
. However, Livewire kind of breaks this ā after subsequent Livewire requests, the "current URL" will be equal to the internal Livewire URL, not the actual page's URL.
An easy fix for this is to save the current URL when the component first loads, using the mount
method. Here's a piece of the Livewire component:
public $currentUrl;
public function mount()
{
$this->currentUrl = url()->current();
}
Now, you can use $currentUrl
in your Livewire component instead of url()->current()
, and it will work as expected.
Tufts Meal Plan Wrapped
Mar 2, 2024
Building an e-ink picture frame that displays an iCloud photo album
Jan 9, 2024
2023 in review
Jan 5, 2024
Subscribe to my newsletter for a monthly round-up of new blog posts and projects Iām working on!