bowett.
Pass query string parameters to Table Builder in v3
Hi, this is the first question I've asked. I feel like I may be missing something so apologies but I have searched and looked at the docs before asking.
I'm trying to pass a query string parameter to a page using Table Builder. For example, if I have a table of cities in the USA which simply contains:
The name of the City
The State the City is in.
I want to set up a page with a route:
/cities/{state}
If I visit /cities/Florida then I get a page of all the cities in Florida.
I've tried doing this by adding a mount function to my Livewire component:
public function mount($state)
{
$this->state = $state;
}
I then use this in my table function:
return $table
->query(City::where('state', $this->state))
This works initially. The problem is if I then try to sort by a column or search inside that table I get an error:
local.ERROR: Property [$state] not found on component.
I think this is because the mount method is not called when the component re-renders.
How should I structure this query so it works?6 replies