### Install Advanced Tables Package with Composer Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Installs the Advanced Tables package using the Composer dependency manager after adding the required repository. This command prompts for authentication credentials, which include your email, license key, and activation domain. ```shell composer require archilex/filament-filter-sets:"^4.0" ``` ```shell Loading composer repositories with package information Authentication required (filament-filter-sets.composer.sh): Username: [licensee-email] Password: [license-key] ``` ```shell Loading composer repositories with package information Authentication required (filament-filter-sets.composer.sh): Username: my_email@gmail.com Password: 8c21df8f-6273-4932-b4ba-8bcc723ef500:my_domain.com ``` -------------------------------- ### Set up Simple Tenancy with Filament Panels Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Guides on configuring simple one-to-many tenancy for Advanced Tables within Filament Panels. This involves specifying the Tenant class and running a migration command. ```php use App\Models\Team; use Filament\Tables\TablesPlugin; // In your Panel Provider public function panel(Panel $panel): Panel { return $panel ->plugin(TablesPlugin::make() ->tenant(Team::class) ); } ``` -------------------------------- ### Create and Configure User Views Livewire Component Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Steps to create a Livewire component for managing user views, copying the necessary logic from the plugin's example, adding the Favorites Bar, and defining a route for access. ```bash php artisan make:livewire ListUserViews ``` ```blade
{{ $this->table }}
``` ```php Route::get('/user-views', App\Livewire\ListUserViews::class)->middleware(['auth', 'verified']); ``` -------------------------------- ### Add Composer Repository for Advanced Tables Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Configures the composer.json file to include the necessary repository for installing the Advanced Tables package. This step is crucial for Composer to locate and download the plugin files. ```json { "repositories": [ { "type": "composer", "url": "https://filament-filter-sets.composer.sh" } ] } ``` -------------------------------- ### SelectFilter for Dropdown Options Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Utilize the SelectFilter for columns that only require a simple dropdown selection without additional operators like 'starts with'. Supports multiple selections. ```php use Archilex\AdvancedTables\Filters\AdvancedFilter; use Archilex\AdvancedTables\Filters\SelectFilter; // ... inside your Table class ->filters([ SelectFilter::make('status') ->options([ 'processing' => 'Processing', 'new' => 'New', 'shipped' => 'Shipped', 'delivered' => 'Delivered', 'cancelled' => 'Cancelled', ]) ->multiple() ]) ``` -------------------------------- ### Setting Default Multi-Sort (FilamentPHP) Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Provides an example for setting default multi-sorting in FilamentPHP tables using the `defaultSort()` method with an array of columns and directions. This feature is noted as coming soon for v4. ```php 'processing' => PresetView::make() ->defaultSort([ 'is_visible' => 'desc', 'price' => 'asc' ]) ``` -------------------------------- ### Configure Quick Save Button Position in Favorites Bar Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Sets the position of the Quick Save button in the Favorites Bar. By default, it appears at the end; setting `position` to 'start' places it at the beginning. ```php AdvancedTablesPlugin::make() ->quickSaveInFavoritesBar(position: 'start') ``` -------------------------------- ### Configure View Manager Position in Favorites Bar Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Determines the placement of the View Manager within the Favorites Bar. By default, it's at the end; setting `position` to 'start' moves it to the beginning. ```php AdvancedTablesPlugin::make() ->viewManagerInFavoritesBar(position: 'start') ``` -------------------------------- ### Configure Custom Tenant Column Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index If your multi-tenancy setup uses a tenant identifier column other than the default `tenant_id`, you can specify it using the `->tenantColumn()` method on the `AdvancedTablesPlugin` object. This allows the plugin to correctly scope data based on your custom column. ```php AdvancedTablesPlugin::make() ->tenantColumn('account_id') ``` -------------------------------- ### Publish and Run Filament Advanced Tables Migrations Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Publishes the database migration files for Filament Advanced Tables and then runs them to set up the necessary database schema. Essential for data persistence. ```bash php artisan vendor:publish --tag="advanced-tables-migrations" php artisan migrate ``` -------------------------------- ### Compile Theme and Upgrade Filament Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Compiles the project's theme assets using npm and then runs the Filament upgrade command to ensure compatibility and apply necessary changes. ```shell npm run build php artisan filament:upgrade ``` -------------------------------- ### Publish and Run Migrations Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Publishes the migration files for Advanced Tables and then runs the database migrations. Ensure user model configurations are updated before migrating if not using defaults. ```shell php artisan vendor:publish --tag="advanced-tables-migrations" php artisan migrate ``` -------------------------------- ### Compile Theme and Upgrade Filament Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Compiles the application's theme assets using npm and then runs the Filament upgrade command. These steps are necessary to apply changes and ensure compatibility. ```bash npm run build php artisan filament:upgrade ``` -------------------------------- ### Add Tenancy Migrations for Advanced Tables Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Provides the Artisan command to add and run necessary migrations for setting up multi-tenancy support in Advanced Tables. ```bash php artisan advanced-tables:add-tenancy ``` -------------------------------- ### Publish Filament Advanced Tables Config Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Publishes the configuration files for Filament Advanced Tables, allowing customization. This is recommended for full control over the package's behavior. ```bash php artisan vendor:publish --tag="advanced-tables-config" ``` -------------------------------- ### Run Filament Upgrade Command Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Execute the Filament upgrade command to apply any necessary framework-level changes after updating dependencies. ```bash php artisan filament:upgrade ``` -------------------------------- ### Publish and Run Migrations Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Publish the plugin's migration files using Artisan and then run the database migrations to update table structures for new features like reorderable columns. ```bash php artisan vendor:publish --tag="advanced-tables-migrations" php artisan migrate ``` -------------------------------- ### Run AddTenancy Artisan Command Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Execute the `php artisan advanced-tables:add-tenancy` command after configuring your tenant model. This command handles the necessary migrations to support multi-tenancy features within the Advanced Tables plugin. ```bash php artisan advanced-tables:add-tenancy ``` -------------------------------- ### Loading Default Preset View (FilamentPHP) Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Shows how to designate a specific Preset View as the default when a page loads using the `default()` method. It also explains how to use a callback for dynamic default view selection. ```php 'processing' => PresetView::make() ->default() ``` -------------------------------- ### Publish Language Files Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Optionally publishes the language files for the Advanced Tables plugin, allowing for translation customization. ```shell php artisan vendor:publish --tag="advanced-tables-translations" ``` -------------------------------- ### Publish Filament Advanced Tables Translations Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Publishes the language files for Filament Advanced Tables, enabling localization. This step is optional but useful for multi-language applications. ```bash php artisan vendor:publish --tag="advanced-tables-translations" ``` -------------------------------- ### Enable Table Loading Overlay Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Activates a skeleton loading overlay for tables to provide visual feedback to users during data loading. This enhances the user experience by indicating activity. ```php AdvancedTablesPlugin::make() ->tableLoadingOverlay() ``` -------------------------------- ### Applying Filters with Filter Builder (FilamentPHP) Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Demonstrates how to apply default filters using the Filter Builder within FilamentPHP Preset Views. It shows how to define filter groups for specific conditions, enabling complex query scopes. ```php 'follow_up' => PresetView::make() ->defaultFilters([ 'advanced_filter_builder' => [ [ // filter group 1 'status' => [ 'value' => 'new' ], 'created_at' => [ 'range' => 'this_month', ], ], [ // filter group 2 (ie: "or") 'status' => [ 'value' => 'cancelled' ], 'created_at' => [ 'range' => 'last_month', ], ], ], ]) ``` ```php 'new_orders_this_quarter' => PresetView::make() ->defaultFilters([ 'advanced_filter_builder' => [ [ // filter group 1 'created_at' => [ 'column' => 'created_at', 'operator' => 'in_the_last', 'value' => 1, 'unit' => 'quarters', ], ], ], ]) ``` -------------------------------- ### Configure Third-Party Tenancy with AdvancedTablesPlugin Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index When using third-party multi-tenancy solutions like Spatie or Tenancy for Laravel, specify your tenant model using the `->tenant()` method on the `AdvancedTablesPlugin` object. This ensures correct integration with external tenancy providers. ```php AdvancedTablesPlugin::make() // For Spatie Multi-tenancy ->tenant(Spatie\Multitenancy\Models\Tenant::class) // For Tenancy for Laravel ->tenant(Stancl\Tenancy\Database\Models\Tenant::class) ``` -------------------------------- ### Show User Views from Multiple Panels Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Configures the `AdvancedTablesPlugin` to display user views from specified panels by passing an array of panel IDs to the `resourcePanels()` method. ```PHP AdvancedTablesPlugin::make() ->resourcePanels(['admin', 'secondaryPanel']) ``` -------------------------------- ### Compile Theme Assets Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Compile your theme's assets using npm after making changes to CSS or other frontend files to reflect the updates. ```bash npm run build ``` -------------------------------- ### Configure Tenancy in advanced-tables.php Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Set the tenant model class in the `advanced-tables.php` configuration file to enable multi-tenancy. This tells the plugin which model represents your tenants. ```php 'tenancy' => [ 'tenant' => App\Models\Team::class, ] ``` -------------------------------- ### Extend UserViewResource for Secondary Panel Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Demonstrates how to extend the plugin's `UserViewResource` to manage user views within a specific panel, ensuring views are scoped to that panel. ```PHP namespace App\Filament\SecondaryPanel\Resources; use App\Filament\SecondaryPanel\Resources\UserViewResource\Pages\ManageUserViews; use Archilex\AdvancedTables\Resources\UserViewResource as Resource; class UserViewResource extends Resource { public static function getPages(): array { return [ 'index' => ManageUserViews::route('/'), ]; } } ``` -------------------------------- ### Configure Favorites Bar Theme Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Allows customization of the visual theme for the Favorites Bar. Six themes are available, including 'Links', 'Simple links', 'Branded tabs', 'Tabs', 'Github' (default), and 'Filament'. The theme can be set using an enum or a string. ```PHP use Archilex\AdvancedTables\Enums\FavoritesBarTheme; AdvancedTablesPlugin::make() ->favoritesBarTheme(FavoritesBarTheme::Filament) ``` ```PHP AdvancedTablesPlugin::make() ->favoritesBarTheme('filament') ``` -------------------------------- ### Fix Deployment Authentication Error Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Provides solutions for common deployment errors related to Composer authentication, specifically the HTTP 401 error. It suggests checking license key format and clearing the Composer cache. ```bash composer clear-cache ``` -------------------------------- ### Create User Policy Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Generates a new policy class for user authorization using the Artisan command. This is the first step in implementing custom policies for user views. ```shell php artisan make:policy UserViewPolicy ``` -------------------------------- ### Integrate Advanced Tables into Panel Pages Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Demonstrates how to extend Filament's `PanelPage` class and use the `AdvancedTables` trait to integrate Advanced Tables functionality into your panel components, resolving potential trait conflicts. ```PHP use Archilex\AdvancedTables\AdvancedTables; use Archilex\AdvancedTables\Livewire\PanelPage; class CustomPage extends PanelPage { use AdvancedTables; ... } ``` -------------------------------- ### Known Issues and Workarounds Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Addresses current known issues in the v4 beta of Advanced Tables. It provides specific PHP code snippets to apply workarounds for problems related to displaying the View Manager as a slideOver and Filament's default defer filters behavior. ```php // Workaround for View Manager slideOver issue: ->viewManagerSlideOver(false) ``` ```php // Workaround for deferring filters issue: ->deferFilters(false) ``` -------------------------------- ### Configure Composer Authentication for Private Packages Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Sets up Composer authentication for private package repositories, typically used for licensed software like Filament Advanced Tables. This involves storing credentials securely. ```bash composer config http-basic.filament-filter-sets.composer.sh your_account_email your_license_key_including_your_fingerprint_domain ``` -------------------------------- ### Create Preset Views with Query Modification Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Demonstrates how to define custom 'Preset Views' programmatically. These views allow modification of the underlying Eloquent query, enabling pre-filtered data displays. ```php use Archilex\AdvancedTables\Components\PresetView; use Archilex\AdvancedTables\AdvancedTables; use App\Filament\Resources\OrderResource\Pages\ListOrders; class ListOrders extends ListOrders { use AdvancedTables; public function getPresetViews(): array { return [ 'processing' => PresetView::make() ->modifyQueryUsing(fn ($query) => $query->where('status', 'processing')), 'delivered' => PresetView::make() ->modifyQueryUsing(fn ($query) => $query->where('status', 'delivered')), ]; } } ``` -------------------------------- ### Configure Preset View Creation in Filament Tables Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Controls whether users can create new Preset Views. Setting `createUsingPresetView(false)` disables this functionality, preventing users from creating their own custom views. ```php public function panel(Panel $panel): Panel { return $panel ->plugins([ AdvancedTablesPlugin::make() ->createUsingPresetView(false) ]) ``` -------------------------------- ### Update ManageUserViews Page Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Shows how to update the `ManageUserViews` page to use the extended `UserViewResource`, integrating the `AdvancedTables` trait. ```PHP namespace App\Filament\SecondaryPanel\Resources\UserViewResource\Pages; use App\Filament\SecondaryPanel\Resources\UserViewResource; use Archilex\AdvancedTables\AdvancedTables; use Filament\Resources\Pages\ManageRecords; class ManageUserViews extends ManageRecords { use AdvancedTables; protected static string $resource = UserViewResource::class; } ``` -------------------------------- ### Enable Favorites Bar Loading Indicator Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Displays a loading indicator when users switch between different views in the Favorites Bar. ```php AdvancedTablesPlugin::make() ->favoritesBarLoadingIndicator() ``` -------------------------------- ### Combine Standard and Advanced Filters Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Shows how to use standard Filament filters alongside the Advanced Filter Builder in the table's filter dropdown. This allows for a mix of simple toggles and the advanced builder. ```php return $table ->columns([ // ... ]) ->filters([ Filter::make('is_active') ->query(fn (Builder $query): Builder => $query->where('is_active', true)) ->toggle(), AdvancedFilter::make(), ]) ``` -------------------------------- ### FilamentPHP: Add Tooltip to Preset View Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Explains how to add a tooltip that appears on hover for a FilamentPHP Preset View using the `tooltip()` method. This enhances user interaction by providing extra context. ```php 'lowStock' => PresetView::make() ->modifyQueryUsing(Product::query()->where('price', '>', 1000)->where('qty', '<', 5)) ->tooltip('High price products with low stock') ``` -------------------------------- ### Configure Managed Preset View Class in Filament Tables Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Specifies a custom class that extends `ManagedPresetView` for storing visibility and sorting configurations between users and Preset Views. This allows for custom logic in managing view states. ```php AdvancedTablesPlugin::make() ->managedPresetView(myCustomManagedPresetView::class) ``` -------------------------------- ### Publish Advanced Tables Language Files Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Command to publish the plugin's language files, allowing for customization of text fields. The files are copied to the `resources\lang\vendor\advanced-tables` directory. Supports English, Spanish, and French translations. ```bash php artisan vendor:publish --tag=advanced-tables-translations ``` -------------------------------- ### Enable Global Favorite User Views - Advanced Tables Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Enables the functionality for users to make a User View a global favorite, automatically adding it to every user's Favorites Bar. This is enabled by calling `quickSaveMakeGlobalFavorite()`. ```php AdvancedTablesPlugin::make() ->quickSaveMakeGlobalFavorite() ``` -------------------------------- ### Configuring Default Columns (FilamentPHP) Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Details how to define the default visible and ordered columns for FilamentPHP tables using the `defaultColumns()` method in Preset Views. It covers reordering and toggling behavior. ```php 'processing' => PresetView::make() ->defaultColumns(['id', 'status', 'customer.name', 'created_at']) ``` -------------------------------- ### Configure Quick Save Button Icon Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Allows customization of the Quick Save button's icon when displayed in the Favorites Bar. Uses the `icon` argument within the `quickSaveInFavoritesBar()` method. ```php AdvancedTablesPlugin::make() ->quickSaveInFavoritesBar(icon: 'heroicon-o-bookmark') ``` -------------------------------- ### Configure Helper Text Visibility - Advanced Tables Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Controls the visibility of helper text for various User View creation/editing toggles. Methods like `quickSaveNameHelperText(false)` can be used to hide specific helper texts. ```php AdvancedTablesPlugin::make() ->quickSaveNameHelperText(false) ->quickSaveFiltersHelperText(false) ->quickSavePublicHelperText(false) ->quickSaveFavoriteHelperText(false) ->quickSaveGlobalFavoriteHelperText(false) ``` -------------------------------- ### Add Advanced Tables Plugin to Filament Panel Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Integrates the Advanced Tables plugin into a Filament panel by instantiating the plugin class within the panel configuration. This makes the plugin's features available in your panel. ```php use Archilex\AdvancedTables\Plugin\AdvancedTablesPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ AdvancedTablesPlugin::make() ]); } ``` -------------------------------- ### Set Initial User View Status Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Configures the default status for new User Views when the Advanced Tables plugin is initialized. By default, this is 'pending'. ```php use Archilex\AdvancedTables\Enums\Status; AdvancedTablesPlugin::make() ->initialStatus(Status::Rejected) ``` -------------------------------- ### Display Query Indicator for Preset Views Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Adds a descriptive badge to the View Summary when a User View is based on a Preset View. This indicator, set via the `indicator()` method, clarifies how the Preset View modifies the query, using the `modifyQueryUsing` closure to define the filtering logic. ```PHP 'honor_roll_students' => PresetView::make() ->modifyQueryUsing(fn ($query) => $query->perfectAttendance() ->perfectGrades() ->withoutBehaviorReports() ) ->indicator('students with perfect attendance, grades, and behavior') ``` -------------------------------- ### Integrate Filter Sets Tailwind and CSS Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Adds the necessary Tailwind and CSS files for Advanced Tables and Filter Sets into your custom Filament theme. This ensures proper styling and functionality. ```css @import '../../../../vendor/filament/filament/resources/css/theme.css'; @import '../../../../vendor/archilex/filament-filter-sets/resources/css/plugin.css'; // Add @source '../../../../app/Filament'; @source '../../../../resources/views/filament'; @source '../../../../vendor/archilex/filament-filter-sets'; // Add ``` -------------------------------- ### Configure New Preset View Sort Position in Filament Tables Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Determines the placement of newly added Preset Views relative to existing user-ordered views. Options are 'before' (default) or 'after', controlling where new views appear in the list. ```php AdvancedTablesPlugin::make() ->newPresetViewSortPosition('after') ``` -------------------------------- ### Configure Table Filters Layout and Form Width Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Demonstrates how to set the filter layout to Modal and configure the form width for better display of filter elements when using the Modal layout. ```php use Archilex\AdvancedTables\Filters\AdvancedFilter; use Filament\Tables\Enums\FiltersLayout; use Filament\Tables\Table; public function table(Table $table): Table { return $table ->filters([ AdvancedFilter::make(), ]) ->filtersLayout(FiltersLayout::Modal) ->filtersFormWidth('3xl'); } ``` -------------------------------- ### Advanced Tables Authorization Policy Methods Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Details the custom policy methods provided by the Advanced Tables plugin for granular control over user view features like public availability, favorites, and icon/color selection. ```APIDOC Advanced Tables Plugin Policy Methods: - makePublic(): Controls who can make a User View publicly available to other users. - makeFavorite(): Controls who can add a User View to their favorites. Typically enabled for all users. - makeGlobalFavorite(): Controls who can make a User View a global favorite for all users. Typically restricted to administrators. - selectIcon(): Controls if users can select an icon for a User View. - selectColor(): Controls if users can select colors for a User View. These methods integrate with Laravel policies to manage authorization for user view functionalities. ``` -------------------------------- ### FilamentPHP: Add Preset View to Favorites Bar Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Shows how to add a FilamentPHP Preset View to the Favorites Bar using the `favorite()` method. Favorited Preset Views appear before User Views in the Favorites Bar. ```php 'processing' => PresetView::make() ->modifyQueryUsing(fn ($query) => $query->where('status', 'processing')) ->favorite(), ``` -------------------------------- ### FilamentPHP: Add Badge to Preset View Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Demonstrates adding a badge to a FilamentPHP Preset View with the `badge()` method, typically used to display counts or status. The badge appears after the label. ```php 'processing' => PresetView::make() ->badge(Order::query()->where('status', 'processing')->count()) ``` -------------------------------- ### Display View Manager as Button with Label Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Configures the View Manager to be displayed as a button with a text label instead of its default icon. This is achieved using the `viewManagerButton()` method. ```php AdvancedTablesPlugin::make() ->viewManagerButton(label: 'Views') ``` -------------------------------- ### Enable Advanced Filter Builder in Filament Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Activates the Advanced Filter Builder for your tables, providing users with a powerful custom query system. Integrate it by adding `AdvancedFilter::make()` to your table's `->filter()` method. ```php use App\Filament\Tables\Filters\AdvancedFilter; // ... return $table ->columns([ // ... ]) ->filters([ AdvancedFilter::make(), ]); ``` -------------------------------- ### FilamentPHP: Apply Default Filters to Preset View Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Shows how to pre-apply filters to a FilamentPHP Preset View using the `defaultFilters()` method. This method takes an array of filter keys and their desired values, enhancing data filtering upon view selection. ```php 'new_this_quarter' => PresetView::make() ->defaultFilters([ 'status' => [ 'value' => 'new', ], 'created_at' => [ 'range' => 'this_quarter', ], ]) ``` -------------------------------- ### Display View Types as Badges Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Configures the View Manager to display view types using badges instead of icons. This is achieved by calling the `viewManagerViewTypeBadges()` method. ```php AdvancedTablesPlugin::make() ->viewManagerViewTypeBadges() ``` -------------------------------- ### Enable Managed Default Views in Filament Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Allows users to manage their preferred default view for tables. To enable this feature, add `->managedDefaultViewsEnabled()` to your panel provider configuration. ```php use AdvancedTablesPlugin; // ... return AdvancedTablesPlugin::make() ->managedDefaultViewsEnabled(); ``` -------------------------------- ### Integrate Advanced Tables Trait in Livewire Component Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Demonstrates how to add the `AdvancedTables` trait to a Livewire component, typically by extending the provided `Page` class to avoid trait conflicts with Filament's `InteractsWithTables`. ```php use Archilex\AdvancedTables\AdvancedTables; use Archilex\AdvancedTables\Livewire\Page; class ListUsers extends Page { use AdvancedTables; // ... component logic } ``` -------------------------------- ### Globally Configure Column Filter Operators Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Set default operator inclusions or exclusions for all filters of a specific type globally by using the `configureUsing()` static method within a service provider's `boot()` method. ```php use Illuminate\Support\ServiceProvider; use Archilex\AdvancedTables\Filters\TextFilter; use Archilex\AdvancedTables\Filters\DateFilter; use Archilex\AdvancedTables\Filters\SelectFilter; use Archilex\AdvancedTables\Filters\NumericFilter; use Archilex\AdvancedTables\Operators\TextOperator; use Archilex\AdvancedTables\Operators\DateOperator; use Archilex\AdvancedTables\Operators\NumericOperator; class AppServiceProvider extends ServiceProvider { public function boot() { TextFilter::configureUsing(function (TextFilter $filter) { return $filter->includeOperators([ TextOperator::CONTAINS, TextOperator::DOES_NOT_CONTAIN ]); }); DateFilter::configureUsing(fn (DateFilter $filter) => $filter->excludeOperators([ DateOperator::YESTERDAY, DateOperator::TODAY, DateOperator::TOMORROW ])); } } ``` -------------------------------- ### FilamentPHP: Conditionally Show/Hide Preset View Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Demonstrates how to conditionally control the visibility of a FilamentPHP Preset View using `visible()` or `hidden()` methods with closures. This allows for dynamic display based on user roles or data. ```php 'processing' => PresetView::make() ->visible(fn (): bool => auth()->isAdmin()) ``` ```php 'processing' => PresetView::make() ->visible(fn (Order $record): bool => auth()->user()->can('viewProcessing', $record)), ``` -------------------------------- ### Configure User View Model Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Specify a custom UserView model to extend its functionality. This allows for custom storage or logic related to user view configurations. ```PHP AdvancedTablesPlugin::make() ->userView(MyCustomUserView::class) ``` -------------------------------- ### FilamentPHP: Customize Preset View Label Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Demonstrates how to set a custom label for a FilamentPHP Preset View. You can pass the label directly to the `make()` method or use the dedicated `label()` method. ```php 'processing' => PresetView::make('Processing orders') ->modifyQueryUsing(fn ($query) => $query->where('status', 'processing')) ->favorite(), ``` ```php 'processing' => PresetView::make() ->label('Processing orders') ->modifyQueryUsing(fn ($query) => $query->where('status', 'processing')) ->favorite(), ``` -------------------------------- ### Modify Default View via Preset Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Allows customization of the default view by creating a 'default' Preset View. This enables modifying the query, setting icons, and marking it as default or favorite. ```php use App\Filament\Resources\Widgets\PresetView; use Illuminate\Database\Eloquent\Builder; use Filament\Support\Facades\Heroicon; public function getPresetViews(): array { return [ 'default' => PresetView::make() ->modifyQueryUsing(fn (Builder $query) => $query->active()) ->icon(Heroicon::Check) ->default() ->favorite() ]; } ``` -------------------------------- ### Configure Authentication Guard Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Sets the authentication guard used by the plugin. If not using Filament's panel, this can be configured directly in the `advanced-tables` config file. ```php 'users' => [ 'auth_guard' => 'web', ] ``` -------------------------------- ### Favorites Bar Visual Customizations Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Provides options to visually enhance the Favorites Bar. This includes adding a divider line between Preset Views and User Views, displaying a lock icon next to Preset Views, and customizing the icon used. ```PHP AdvancedTablesPlugin::make() ->favoritesBarDivider() ``` ```PHP AdvancedTablesPlugin::make() ->presetViewLockIcon() ``` ```PHP AdvancedTablesPlugin::make() ->presetViewLockIcon('heroicon-o-star') ``` -------------------------------- ### Configure Filter Picker Columns Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Sets the number of columns the filter picker occupies at the 'lg' breakpoint. Supports an integer for a fixed column count or an array for responsive column configurations. ```php use Archilex\AdvancedTables\Filters\AdvancedFilter; AdvancedFilter::make() ->filterPickerColumns(2); ``` ```php use Archilex\AdvancedTables\Filters\AdvancedFilter; AdvancedFilter::make() ->filterPickerColumns(['sm' => 2]); ``` -------------------------------- ### Update Composer Dependency for v4 Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Update the `composer.json` file to specify the new version of the Advanced Tables plugin dependency. ```json "archilex/filament-filter-sets": "^4.0" ``` -------------------------------- ### Integrate Plugin CSS into Filament Theme Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Add the plugin's CSS file to your custom Filament theme by importing it alongside the main Filament theme CSS and specifying plugin source paths. ```css @import '../../../../vendor/filament/filament/resources/css/theme.css'; @import '../../../../vendor/archilex/filament-filter-sets/resources/css/plugin.css'; // Add @source '../../../../app/Filament'; @source '../../../../resources/views/filament'; @source '../../../../vendor/archilex/filament-filter-sets'; // Add ``` -------------------------------- ### FilamentPHP: Add Icon to Preset View Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Illustrates how to assign an icon to a FilamentPHP Preset View using the `icon()` method. The icon is displayed before the view's name by default. ```php 'processing' => PresetView::make() ->modifyQueryUsing(fn ($query) => $query->where('status', 'processing')) ->icon('heroicon-o-refresh'), ``` -------------------------------- ### Display Quick Save Form as Modal Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Changes the behavior of the Quick Save form from a slide-over to a modal dialog. This is achieved by passing `false` to the `quickSaveSlideOver()` method. ```php AdvancedTablesPlugin::make() ->quickSaveSlideOver(false) ``` -------------------------------- ### Persist Active Preset View to Session in Filament Tables Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Enables persistence of the currently active Preset View in the user's session. This allows users to navigate away from the table and return to the same view configuration. ```php AdvancedTablesPlugin::make() ->persistActiveViewInSession() ``` -------------------------------- ### Integrate Advanced Tables CSS Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Adds the custom CSS file for Filament Advanced Tables to the main application CSS file. This ensures the plugin's styles are correctly applied. ```css @import '../../vendor/archilex/filament-filter-sets/resources/css/plugin.css'; @source '../../vendor/archilex/filament-filter-sets'; ``` -------------------------------- ### Configure Custom User Class Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Allows specifying a custom User model class if it deviates from Laravel's default `AppModelsUser`. This configuration should be done before running migrations. ```php AdvancedTablesPlugin::make() ->user(MyUser::class) ``` -------------------------------- ### Configure Color Picker Colors Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Customize the available colors in the color picker. You can use Filament's default colors or register custom ones. ```PHP AdvancedTablesPlugin::make() ->quickSaveColors([ 'primary', 'warning', 'gray', ]) ``` ```PHP AdvancedTablesPlugin::make() ->quickSaveColors([ 'primary', 'success', 'indigo', 'pink', 'zinc', ]) ``` -------------------------------- ### TextFilter with Options from Model/Relationship Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Configure a TextFilter to use a dropdown of options, either by providing a static array or by fetching options from a model relationship. Supports multiple selections. ```php use Archilex\AdvancedTables\Filters\AdvancedFilter; use Archilex\AdvancedTables\Filters\TextFilter; use App\Models\Country; // Assuming Country model exists // ... inside your Table class ->filters([ TextFilter::make('country') ->options(fn () => Country::all()->pluck('name', 'id')), TextFilter::make('customer.name') ->relationship(name: 'customer', titleAttribute:'name') ->multiple() ->preload() ]) ``` -------------------------------- ### Configure Managed User View Class Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Set a custom ManagedUserView class to manage visibility and sort order between users and their views. This is useful for custom management logic. ```PHP AdvancedTablesPlugin::make() ->managedUserView(myCustomManagedUserView::class) ``` -------------------------------- ### Enable Favorites Bar Divider Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Adds a visual divider line in the Favorites Bar to distinguish between Preset Views and User Views. ```php AdvancedTablesPlugin::make() ->favoritesBarDivider() ``` -------------------------------- ### FilamentPHP: Set Color for Preset View Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Explains how to display a FilamentPHP Preset View with a specific color using the `color()` method. Accepts Filament's default colors or custom registered colors. ```php 'processing' => PresetView::make() ->modifyQueryUsing(fn ($query) => $query->where('status', 'processing')) ->color('warning'), ``` -------------------------------- ### Add Favorites Bar Component to Blade Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Shows how to include the `Advanced Tables` Favorites Bar component in your Blade template for a panel page. It highlights the need for Tailwind's `space-y-6` class for proper layout. ```Blade
{{ $this->table }}
``` -------------------------------- ### Configure Favorites Bar Size Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Adjusts the size of links displayed in the Favorites Bar, allowing more links to be visible. Uses predefined enum values for sizing. ```php use Filament\Support\Enums\ActionSize; AdvancedTablesPlugin::make() ->favoritesBarSize(ActionSize::Small) ``` -------------------------------- ### Add Icons to Filter Picker Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Enables the addition of icons to the filter picker by mapping filter names to specific icon classes using the `icons()` method. ```php use Archilex\AdvancedTables\Filters\AdvancedFilter; AdvancedFilter::make() ->filters([ // ... other filters ]) ->icons([ 'status' => 'heroicon-o-clock', 'currency' => 'heroicon-o-currency-euro', 'customer' => 'heroicon-o-user', 'created_at' => 'heroicon-o-calendar', ]); ``` -------------------------------- ### Display Helper Text for Preset View Usage Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Enables helper text within the Save View slideover or modal. This text informs users that they have selected a Preset View as a base and that the filtering applied by the Preset View cannot be removed. ```PHP AdvancedTablesPlugin::make() ->quickSaveActivePresetViewHelperText() ``` -------------------------------- ### Setting Default Sort Order (FilamentPHP) Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Illustrates how to set a default sort column and direction for FilamentPHP tables via the `defaultSort()` method in Preset Views. It also mentions the upcoming multi-sort functionality. ```php 'processing' => PresetView::make() ->defaultSort('total_price') ``` ```php 'processing' => PresetView::make() ->defaultSort('total_price', 'desc') ``` -------------------------------- ### Enable Reorderable Columns in Filament v4 Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Enables the reorderable columns feature for Filament tables. This functionality is now part of Filament v4 core via the Column Manager. Add `->reorderableColumns()` to your table definition. ```php return $table ->reorderableColumns(); ``` -------------------------------- ### Display View Manager as SlideOver Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Changes the View Manager's display behavior from a dropdown to a slide-over panel. This is configured by calling the `viewManagerSlideOver()` method. ```php AdvancedTablesPlugin::make() ->viewManagerSlideOver() ``` -------------------------------- ### Customize User Views Resource Navigation Group Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Customizes the navigation group for the User Views Resource. This helps organize your Filament panel navigation by assigning the resource to a specific group. ```php AdvancedTablesPlugin::make() ->resourceNavigationGroup('Settings') ``` -------------------------------- ### Add AdvancedTables Trait to Simple Resource Table Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Integrate the `AdvancedTables` trait into the `ListRecords` class of your Filament Simple Resource (modal) to enable advanced table functionality. ```php use Archilex\AdvancedTables; class ManagesCustomers extends ListRecords { use AdvancedTables; ``` -------------------------------- ### Display Both Public and Global View Indicators Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Enables the display of both public and global favorite indicators when a view satisfies both conditions. By default, only the global indicator is shown to reduce clutter. This behavior is controlled by the `viewManagerPublicIndicatorWhenGlobal()` method. ```php AdvancedTablesPlugin::make() ->viewManagerPublicIndicatorWhenGlobal() ``` -------------------------------- ### Enable Search in Filter Picker Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Adds a search input field to the filter picker, facilitating easier navigation when a large number of filters are available. ```php use Archilex\AdvancedTables\Filters\AdvancedFilter; AdvancedFilter::make() ->filterPickerSearch(); ``` -------------------------------- ### FilamentPHP: Change Preset View Badge Color Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Shows how to customize the color of a badge displayed on a FilamentPHP Preset View using the `badgeColor()` method. Accepts Filament's standard color names. ```php 'processing' => PresetView::make() ->badge(Order::query()->where('status', 'processing')->count()) ->badgeColor('warning') ``` -------------------------------- ### Configure Custom User Table Name Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Specifies the name of the database table used for user data if it's not the default 'users'. This ensures the plugin correctly references user records. ```php AdvancedTablesPlugin::make() ->userTable('my_users_table') ``` -------------------------------- ### Configure User Name Column Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Sets the column name used for displaying user names, accommodating custom column names like 'first_name' instead of the default 'name'. It also supports virtual columns for combined names. ```php AdvancedTablesPlugin::make() ->userTableNameColumn('first_name') ``` ```php $table->string('full_name')->virtualAs('concat(first_name, \' \', last_name)'); AdvancedTablesPlugin::make() ->userTableNameColumn('full_name') ``` -------------------------------- ### Preserve User Selections in Filament Tables Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Allows preserving user-applied filters, toggled columns, sort column, and sort direction when switching Preset Views. Use `preserveAll()` for all settings or individual methods for fine-grained control. ```php 'processing' => PresetView::make() ->preserveAll() ``` ```php 'processing' => PresetView::make() ->preserveFilters() ->preserveToggledColumns() ->preserveSortColumn() ->preserveSortDirection() ``` -------------------------------- ### Add AdvancedTables Trait to Resource Table Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Integrate the `AdvancedTables` trait into the `ListRecords` class of your Filament Resource to enable advanced table functionality. ```php use Archilex\AdvancedTables; class ListProducts extends ListRecords { use AdvancedTables; ``` -------------------------------- ### Include Specific Columns for Filtering Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Configures the Advanced Filter Builder to only consider a specified list of columns for filtering. This is useful for performance or to limit filtering options. ```php AdvancedFilter::make() ->includeColumns([ 'is_active', 'currency', 'address.city', ]); ``` -------------------------------- ### Force Filter Builder to Open as SlideOver Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Configures the filter builder to always open as a slideOver or modal by utilizing Filament's `filtersTriggerAction()` method with the `slideOver()` option. ```php use Archilex\AdvancedTables\Filters\AdvancedFilter; use Filament\Tables\Actions\Action; use Filament\Tables\Table; public function table(Table $table): Table { return $table ->filters([ AdvancedFilter::make(), ]) ->filtersFormWidth('md') ->filtersTriggerAction( fn (Action $action) => $action->slideOver() ); } ``` -------------------------------- ### Globally Configure Column Filter Default Operator Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Configure the default operator for all filters of a specific type globally using `configureUsing()` in a service provider. This can include conditional logic via closures. ```php use Illuminate\Support\ServiceProvider; use Archilex\AdvancedTables\Filters\TextFilter; use Archilex\AdvancedTables\Filters\DateFilter; use Archilex\AdvancedTables\Filters\SelectFilter; use Archilex\AdvancedTables\Filters\NumericFilter; use Archilex\AdvancedTables\Operators\TextOperator; use Archilex\AdvancedTables\Operators\DateOperator; use Archilex\AdvancedTables\Operators\NumericOperator; class AppServiceProvider extends ServiceProvider { public function boot() { TextFilter::configureUsing(fn (TextFilter $filter) => $filter->defaultOperator(TextOperator::CONTAINS)); DateFilter::configureUsing(fn (DateFilter $filter) => $filter->defaultOperator(DateOperator::TODAY)); SelectFilter::configureUsing(fn (SelectFilter $filter) => $filter->defaultOperator(TextOperator::IS)); NumericFilter::configureUsing(fn (NumericFilter $filter) => $filter->defaultOperator(NumericOperator::GREATER_THAN)); } } ``` -------------------------------- ### Automatically Generate Column Filters Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Automatically generates column filters for compatible table columns, making them available in the Advanced Filter Builder. Use the `->includeColumns()` method on `AdvancedFilter::make()` to enable this. ```php use App\Filament\Tables\Filters\AdvancedFilter; // ... return $table ->filters([ AdvancedFilter::make() ->includeColumns(), ]); ``` -------------------------------- ### Define User View Status Enum Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Defines the possible statuses for User Views using Filament's enum system. This allows for clear, type-safe status management within the application. ```php use FilamentSupportContracts\HasColor; use FilamentSupport\Contracts\HasLabel; enum Status: string implements HasLabel, HasColor { case Approved = 'approved'; case Pending = 'pending'; case Rejected = 'rejected'; } ``` -------------------------------- ### Display Reset Link in View Manager Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Includes a 'Reset' link in the View Manager, which functions identically to clicking the 'Default View' button. This is enabled using the `viewManagerResetView()` method. It also supports hiding the 'Default View' button from the Favorites Bar. ```php AdvancedTablesPlugin::make() ->viewManagerResetView() ``` -------------------------------- ### Hide Quick Save and View Manager Buttons Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Allows hiding the Quick Save button and the View Manager button from the Favorites Bar to optimize space. This is achieved by setting `quickSaveInFavoritesBar(false)` and `viewManagerInFavoritesBar(false)`, respectively. The View Manager is also explicitly set to appear within the table using `viewManagerInTable()`. ```php AdvancedTablesPlugin::make() ->quickSaveInFavoritesBar(false) ->viewManagerInFavoritesBar(false) ->viewManagerInTable() ->viewManagerSaveView() ``` -------------------------------- ### Add Custom Filters to Advanced Tables Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Demonstrates how to add custom Filament filters to the Advanced Filter Builder. Custom filters can be reused and placed in 'or groups'. Filters with names matching table columns override default column filters. ```php AdvancedFilter::make() ->filters([ Filter::make('is_active') ->query(fn (Builder $query): Builder => $query->where('is_active', true)) ->toggle(), ]) ``` -------------------------------- ### Display Quick Save Button in Table Toolbar Source: https://filamentphp.com/plugins/kenneth-sese-advanced-tables/index Configures the Quick Save button to appear in the table's toolbar instead of the Favorites Bar. This involves disabling it in the Favorites Bar and enabling it in the table using `quickSaveInTable()`. ```php AdvancedTablesPlugin::make() ->quickSaveInFavoritesBar(false) ->quickSaveInTable() ```