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
bwurtz9994mo 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
bwurtz9994mo ago
Filament
Archivable by OKE Online - Filament
This plugin allows you to archive, unarchive, and filter archived records in your application.
Sourabh
SourabhOP4mo ago
Thank you for your prompt response but I want to use filter as a table tab. Hope anyone can give some solution.
LeandroFerreira
LeandroFerreira4mo ago
the issue happens when you try to search something? I didn't understand the issue..
Sourabh
SourabhOP4mo 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
LeandroFerreira4mo ago
you mean, ->where('is_archived', true) isn't working?
Sourabh
SourabhOP4mo ago
Yes, exactly
LeandroFerreira
LeandroFerreira4mo ago
is it a boolean column? new, on_site work?
Sourabh
SourabhOP4mo ago
Yes
LeandroFerreira
LeandroFerreira4mo ago
?activeTab=archived in the url?
Sourabh
SourabhOP4mo ago
Yes,
No description
LeandroFerreira
LeandroFerreira4mo ago
did you create a global scope to filter it globally?
Sourabh
SourabhOP4mo ago
No, not created
LeandroFerreira
LeandroFerreira4mo ago
maybe you could provide a minimal repo on github to reproduce this issue
Sourabh
SourabhOP4mo ago
Okay, I will share the git repo with same issue
LeandroFerreira
LeandroFerreira4mo ago
if ->where('is_archived', false) works, true was supposed to work as well
Sourabh
SourabhOP4mo ago
I have checked with false also but still it is not working
LeandroFerreira
LeandroFerreira4mo ago
weird
Sourabh
SourabhOP4mo ago
Yeah, it's weird
Want results from more Discord servers?
Add your server