Overview
Tables are the backbone of the hub and how data is displayed. Therefore it’s important they can be extended when needed and also allow you to create your own tables when developing add-ons.
All tables use a TableBuilder class to add columns, filters and actions. It’s these classes that can be extended in order to provider a richer experience in the hub when displaying data.
Available builders
Lunar\Hub\Tables\Builders\CustomersTableBuilder
Lunar\Hub\Tables\Builders\OrdersTableBuilder
Lunar\Hub\Tables\Builders\ProductsTableBuilder
Lunar\Hub\Tables\Builders\ProductTypesTableBuilder
Lunar\Hub\Tables\Builders\ProductVariantsTableBuilder
Getting the builder instance
You can resolve each builder class as a singleton from the container. Generally this can be done via a service provider:
Adding columns
When adding columns, there is some flexibility on how they are rendered.
Standard
This is the default behaviour and will use the view provided by Lunar.
Laravel Component
You can render your own Laravel component
This will pass through the instance of the row so it’s available:
Livewire Component
When rendered, the current record will be passed through via a prop.
Positioning
You can specify a position for the new column by defining which column it should appear after.
TextColumn
BadgeColumn
ImageColumn
Calling heading(false) will prevent heading text from being displayed.
AvatarColumn
By calling gravatar() we’re telling the column to convert it to a hash that Gravatar can understand and render.
StatusColumn
Adding Filters
SelectFilter
DateFilter
Actions
Single actions will populate a dropdown on each row that will display the registered actions when clicked.
Action
Bulk Actions
Bulk actions are available when one or more rows are selected on the table. When an action is clicked the underlying Livewire component will be called with the selected ID’s.
Bulk Action
The underlying Livewire component
Customising the query
If you add custom columns which reference relations, or want to make some performance improvements, it can be useful to customise the underlying query.
Creating a new table
If you need to create a table for your own add-on, simply create a Livewire component which extends the Table component.
Table component
Table builder class
Out the box, the table will be loaded with a base TableBuilder class. In most cases this should be enough, however you are free to add your own if needed.
Create a new table builder class
Then update the reference on your Table component.