F
Filament3mo ago
Tjiel

Parameter being null after table action

I have a widget that refreshes the page with a custom parameter. I use this parameter to manipulate a different widget, which needs a page refresh. And to update the getTableQuery method.
protected function getTableQuery(): Builder
{
if (Request::query('location')) {
switch (Request::query('location')){
case 'all': return parent::getTableQuery();
case 'allDeleted': {
return Asset::onlyTrashed();
}
default: {
$location = Location::findOrFail(Request::query('location'));
$assetIds = $location->assets->pluck('id')->toArray();
return parent::getTableQuery()->whereIn('id', $assetIds);
}
}
}
dd(Request::query('location'));
$location = Location::first();
if ($location) {
$assetIds = $location->assets->pluck('id')->toArray();
return parent::getTableQuery()->whereIn('id', $assetIds);
}
return parent::getTableQuery();
}
protected function getTableQuery(): Builder
{
if (Request::query('location')) {
switch (Request::query('location')){
case 'all': return parent::getTableQuery();
case 'allDeleted': {
return Asset::onlyTrashed();
}
default: {
$location = Location::findOrFail(Request::query('location'));
$assetIds = $location->assets->pluck('id')->toArray();
return parent::getTableQuery()->whereIn('id', $assetIds);
}
}
}
dd(Request::query('location'));
$location = Location::first();
if ($location) {
$assetIds = $location->assets->pluck('id')->toArray();
return parent::getTableQuery()->whereIn('id', $assetIds);
}
return parent::getTableQuery();
}
This is working fine on the initial loading of the page, as you would expect the Request::query('location') is present and it applies the correct filters. The problem comes when trying to do a table action like delete, restore or any custom action. Then it is null, as i can see using the dd method. Why might this be and how can i make it so it will detect the location.
5 Replies
krekas
krekas3mo ago
it's how livewire works. you don't have the request. can't you use native table filters?
Tjiel
Tjiel3mo ago
I need to reload the page for the mapping tool, I could not find a good way achieve this using the native filters. Maybe if there is a way to change the table filters from the inside of the widget on load it could work.
krekas
krekas3mo ago
What do you need to map? You return two times query without params so no filters. Add filters for other conditions
Tjiel
Tjiel3mo ago
The two times query without params are for when there is no location yet created, or for when the location parameter is all
krekas
krekas3mo ago
which means no filters selected
Want results from more Discord servers?
Add your server
More Posts
Unable to add form actions to modalHi, I've got a resource with a simple form for creating / editing. I've got a table that displays Is it possible to adjust the navigation panel width to be even smaller?I already sent the width of the content to the maximum possible option but there's still so much wasFilament 3 - Multi Tenancy Upload Image ErrorI encountered this error: Unable to retrieve the file_size for file at location: livewire-tmp/GfJyK6Updating Standalone Action's modal description based on the argument passed to the formI have a standalone action that launches a modal. I want to update the modal description based on thSpark Billable Slug redirects to wrong urlI am using the Spark Billing Portal with Filament and everything is working so far, except the rediIs it possible to pre-populate this form with some data?I have a custom widget, with a heading defined like so: ```php <div class="flex items-center justifTrouble with Export/Import in Laravel Filament Admin Panel: 'Login Route Not Found' ErrorHi, I'm currently using the Laravel Filament admin panel for my application. I've been working on geHow can personalize the buttons style for Create, Delete, Cancel, SaveHey guys, i working and configuring a new theme in my project, i inspect the desing and can see the Getting Error in Sudden Change in TabI'm using a Custom table which is changing through a Year filter and I 'm getting Typed property FilHow do I filter data by permissionI have a table of Orders. So i have OrderResource but how do i filter the order based on type. For