Build Link to (Url for) table with set filters

Hey ho I have a table with filters in a complex structure like this:
return $table
->query(Model::query())
->filters([
Filter::make('exampleFilters')
->form([
Tabs::make('Heading')
->tabs([
Tabs\Tab::make(basicFilters)
->schema(FilterTabs::listBasicFilter()),
return $table
->query(Model::query())
->filters([
Filter::make('exampleFilters')
->form([
Tabs::make('Heading')
->tabs([
Tabs\Tab::make(basicFilters)
->schema(FilterTabs::listBasicFilter()),
Inside listBasicFilter the following is returned:
return [
Grid::make([
'sm' => 1,
'md' => 2,
])
->schema([
Grid::make(2)
->columnSpan(1)
->columns(['default' => 2, 'md' => 2, 'lg' => 2])
->schema([
Select::make('OtherModel_id')
->hiddenLabel()
->reactive()
}),
return [
Grid::make([
'sm' => 1,
'md' => 2,
])
->schema([
Grid::make(2)
->columnSpan(1)
->columns(['default' => 2, 'md' => 2, 'lg' => 2])
->schema([
Select::make('OtherModel_id')
->hiddenLabel()
->reactive()
}),
After setting a Filter (OtherModel_id) the query is updated within:
->query(fn ($query, $data) => FilterTabs::listQueryFunction($query, $data))
->query(fn ($query, $data) => FilterTabs::listQueryFunction($query, $data))
listQueryFunction than returns:
if (!empty($data['OtherModel_id'])) {
$query->where('otherModel_id',$data['OtherModel_id']);
if (!empty($data['OtherModel_id'])) {
$query->where('otherModel_id',$data['OtherModel_id']);
Now i want to build a link to this table with a preset filter. I alredy tried:
list?exampleFilters[OtherModel_id][values][0]=220
list?exampleFilters[OtherModel_id][values][0]=220
(220 is the id of a specific OtherModel) This is linking to the list but the filter is not set. Does sombody know how to build a link to this list with a preset filter? Thanks alot in advance
Solution:
Make it a property on ListPage and add Livewires #Url attribute
Jump to solution
2 Replies
Solution
Dennis Koch
Dennis Koch4w ago
Make it a property on ListPage and add Livewires #Url attribute
ArnoNym
ArnoNym4w ago
thanks alot @Dennis Koch