CustomerResource:
Columns
Resource column classes are located in theFilament\Resources\Tables\Columns namespace.
All columns have access to the following customization methods:
Since sorting and searching are done by the database,sortable()andsearchable()will not be fully functional when using a customgetValueUsing()callback.
Displaying Relationship Data
You set up columns that display results from a related model using dot syntax in its name:customer relationship on the parent model and output the related customer’s name.
Calling Actions
You may want something to happen when a cell is clicked. Usually, this is opening a URL, or running a custom Livewire action. To open a URL when a cell is clicked, a callback is used to generate the destination. For example:website, and redirect the user to it when they click. The second parameter to url(), true, means that the website will open in a new tab when clicked.
Alternatively, you may specify a custom Livewire action that should run when the column is clicked. The primary key of the clicked record will be passed as a parameter to the action:
editUsername() Livewire action when clicked.
Boolean
ThetrueIcon() and falseIcon() methods support the name of any Blade icon component, and passes a set of formatting classes to it. By default, the Blade Heroicons package is installed, so you may use the name of any Heroicon out of the box. However, you may create your own custom icon components or install an alternative library if you wish.
Icon
Theoptions() method supports the names of any Blade icon components, and passes a set of formatting classes to them. By default, the Blade Heroicons package is installed, so you may use the name of any Heroicon out of the box. However, you may create your own custom icon components or install an alternative library if you wish.
Image
Text
Other column types are coming soon.
Developing Custom Column Types
To create a new column type, which may be used in any table, you may generate a class and cell view using:View component, and passing the name of a cell $view in your app:
Filters
Filters are used to scope results in the table. Here is an example of a filter at allows only customers with atype of individual to be shown in the table:
defaultFilter() on the Table object:
Reusable Filters
You may wish to create a filter that you may reuse across multiple tables. To create a reusable filter, you may use the following command:app/Filament/Resources/Tables/Filters directory:
apply() method of that class:
Currently, filters are static and only one may be applied at a time. Parameter-based filters and support for applying multiple filters at once is coming soon.
Context Customization
You may customize tables based on the page they are used. To do this, you can chain theonly() or except() methods onto any column or filter.
individuals filter will only() be available on the ListCustomers page.
name column will be primary, except() on the ListCustomers page.
This is an incredibly powerful pattern, and allows you to completely customize a table contextually by chaining as many methods as you wish to the callback.