Filament Table tab

I'm trying to apply a condition on the Filament table tab so that when is_archived = 1, it should display in the 'Archived' tab. However, it's not working in my case. I've attached the code for your reference.
<?php
public function getTabs(): array
{
return [
'new' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->whereNull('magento_id')
->where('is_enabled', false)
->where('is_archived', false)->orderBy('created_at', 'desc')),
'on_site' => Tab::make()
->label('On Site')
->modifyQueryUsing(fn (Builder $query) => $query
->where('is_enabled', true)
->where('is_archived', false)),
'archived' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->where('is_archived', true)),
];
}?>
<?php
public function getTabs(): array
{
return [
'new' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->whereNull('magento_id')
->where('is_enabled', false)
->where('is_archived', false)->orderBy('created_at', 'desc')),
'on_site' => Tab::make()
->label('On Site')
->modifyQueryUsing(fn (Builder $query) => $query
->where('is_enabled', true)
->where('is_archived', false)),
'archived' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->where('is_archived', true)),
];
}?>
19 Replies
bwurtz999
bwurtz9993mo ago
I'm not sure why your query isn't working, but there is a Filament plugin that can handle all of this for you
bwurtz999
bwurtz9993mo ago
Filament
Archivable by OKE Online - Filament
This plugin allows you to archive, unarchive, and filter archived records in your application.
Sourabh
Sourabh3mo ago
Thank you for your prompt response but I want to use filter as a table tab. Hope anyone can give some solution.
LeandroFerreira
LeandroFerreira3mo ago
the issue happens when you try to search something? I didn't understand the issue..
Sourabh
Sourabh3mo ago
No, I am not searching anything, I am just clicking on the Archived tab. And for that below code executes (Just refer the 'archived' key):
<?php
public function getTabs(): array
{
return [
'new' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->whereNull('magento_id')
->where('is_enabled', false)
->where('is_archived', false)->orderBy('created_at', 'desc')),
'on_site' => Tab::make()
->label('On Site')
->modifyQueryUsing(fn (Builder $query) => $query
->where('is_enabled', true)
->where('is_archived', false)),
'archived' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->where('is_archived', true)),
];
}?>
<?php
public function getTabs(): array
{
return [
'new' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->whereNull('magento_id')
->where('is_enabled', false)
->where('is_archived', false)->orderBy('created_at', 'desc')),
'on_site' => Tab::make()
->label('On Site')
->modifyQueryUsing(fn (Builder $query) => $query
->where('is_enabled', true)
->where('is_archived', false)),
'archived' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->where('is_archived', true)),
];
}?>
LeandroFerreira
LeandroFerreira3mo ago
you mean, ->where('is_archived', true) isn't working?
Sourabh
Sourabh3mo ago
Yes, exactly
LeandroFerreira
LeandroFerreira3mo ago
is it a boolean column? new, on_site work?
Sourabh
Sourabh3mo ago
Yes
LeandroFerreira
LeandroFerreira3mo ago
?activeTab=archived in the url?
Sourabh
Sourabh3mo ago
Yes,
No description
LeandroFerreira
LeandroFerreira3mo ago
did you create a global scope to filter it globally?
Sourabh
Sourabh3mo ago
No, not created
LeandroFerreira
LeandroFerreira3mo ago
maybe you could provide a minimal repo on github to reproduce this issue
Sourabh
Sourabh3mo ago
Okay, I will share the git repo with same issue
LeandroFerreira
LeandroFerreira3mo ago
if ->where('is_archived', false) works, true was supposed to work as well
Sourabh
Sourabh3mo ago
I have checked with false also but still it is not working
LeandroFerreira
LeandroFerreira3mo ago
weird
Sourabh
Sourabh3mo ago
Yeah, it's weird
Want results from more Discord servers?
Add your server