PHP code example of sehsah / filament-remember-table

1. Go to this page and download the library: Download sehsah/filament-remember-table library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sehsah / filament-remember-table example snippets


use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
use Sehsah\FilamentRememberTable\Concerns\HasRememberTable;

class ListOrders extends ListRecords
{
    use HasRememberTable;

    protected static string $resource = OrderResource::class;

    protected function getHeaderActions(): array
    {
        return [
            ...$this->getTableViewActions(),
            CreateAction::make(),
        ];
    }
}

use Sehsah\FilamentRememberTable\PresetView;

public function getPresetTableViews(): array
{
    return [
        PresetView::make('Pending orders')
            ->icon('heroicon-o-clock')
            ->filters(['status' => ['value' => 'pending']])
            ->sort('created_at', 'desc')
            ->default(), // used when the user has no default of their own

        PresetView::make('Big spenders')
            ->filters(['total' => ['total_from' => 1000]])
            ->hiddenColumns(['notes'])
            ->visibleColumns(['customer.email'])
            ->grouping('customer.name'),
    ];
}

public function getTableViewsKey(): string
{
    return static::class . ':' . $this->type;
}

return [
    'table_name' => 'remember_table_views',
    'model' => \Sehsah\FilamentRememberTable\Models\TableView::class,

    'remember' => [ /* see table above */ ],

    'allow_public_views' => true,        // "Share with everyone" toggle
    'apply_default_view_on_load' => true,
    'scope_to_tenant' => true,           // separate views per Filament tenant
    'max_views_per_table' => 50,         // per user; null for no limit
];

use HasRememberTable {
    saveTableViewAction as baseSaveTableViewAction;
}

public function saveTableViewAction(): \Filament\Actions\Action
{
    return $this->baseSaveTableViewAction()->modalWidth('lg');
}
bash
php artisan vendor:publish --tag="filament-remember-table-config"
php artisan vendor:publish --tag="filament-remember-table-migrations"
php artisan migrate