Skip to content

Instantly share code, notes, and snippets.

@neverything
Last active March 17, 2025 06:03
Show Gist options
  • Save neverything/e1dda5018632e06aa5794179294b7e42 to your computer and use it in GitHub Desktop.
Save neverything/e1dda5018632e06aa5794179294b7e42 to your computer and use it in GitHub Desktop.
Filament persist table filters, sort and search per tenant: https://silvanhagen.com/writing/filament-persist-filters-tenant/
<?php
namespace App\Filament\Traits;
use Filament\Facades\Filament;
trait HasTenantAwareSessionKeys
{
public function getTableFiltersSessionKey(): string
{
$table = md5($this::class.Filament::getTenant());
return "tables.{$table}_filters";
}
public function getTableSearchSessionKey(): string
{
$table = md5($this::class.Filament::getTenant());
return "tables.{$table}_search";
}
public function getTableSortSessionKey(): string
{
$table = md5($this::class.Filament::getTenant());
return "tables.{$table}_sort";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment