How to Reset the Active Tab in Table

So, I am displaying tabs dynamically, and it works, but when a User deletes all of the records that are "connected", even though all of the tabs disappear correctly and the default table from index view is shown, the "connected" active tab query string in the URL is still shown. Setting it to null doesn't work and instead just makes the query string in the URL actually be ?activeTab=null. Which seems odd. The only way I could get it to work correctly is by redirecting to the index view URL. Is there a simpler way?
public function getTabs(): array
{
if (! Account::where('is_connected_account', true)->exists()) {
if ($this->activeTab === 'connected') {
$this->redirect(url(static::getUrl()));
}

return [];
}

return [
'manual' => Tab::make('Manual')
->modifyQueryUsing(function (Builder $query) {
$query->where('is_connected_account', false)
->whereNull('available_balance');
}),
'connected' => Tab::make('Connected')
->modifyQueryUsing(function (Builder $query) {
$query->where('is_connected_account', true)
->whereNotNull('available_balance');
}),
];
}
public function getTabs(): array
{
if (! Account::where('is_connected_account', true)->exists()) {
if ($this->activeTab === 'connected') {
$this->redirect(url(static::getUrl()));
}

return [];
}

return [
'manual' => Tab::make('Manual')
->modifyQueryUsing(function (Builder $query) {
$query->where('is_connected_account', false)
->whereNull('available_balance');
}),
'connected' => Tab::make('Connected')
->modifyQueryUsing(function (Builder $query) {
$query->where('is_connected_account', true)
->whereNotNull('available_balance');
}),
];
}
0 Replies
No replies yetBe the first to reply to this messageJoin