Tables
Introduction
The table plugin function allows you to initialize, configure, and display a table builder inline within a view.
Displaying Tables
The easiest way to display a table is to use the table function and specify the namespace and stream slug.
The render method will trigger display but it is optional as __toString will result in the same thing.
{{ table('books', 'reviews').render()|raw }}
You may want to take more control and set the table to a variable and use it.
{% set table = table('books', 'reviews') %}
{{ table.render|raw }}
Binding Table Builders
The table function makes use of a generic table builder class by default. Often times, however, you want to build and use a specific table builder. The easiest way to use said builder in the table function is to bind it to the service container.
You can define a table builder binding within a service provider.
Service Providers{.link} Table Builders{.link}
protected $bindings = [
'employment_applicants_table' => \Anomaly\ExampleModule\Applications\Table\PublicApplicantsTableBuilder::class
];
After binding the table builder you can use it by specifying the bound key.
{{ table('employment_application').render()|raw }}
Table Components
You can work with table components similarly as to how you would work with a table builder.
Table Builders{.link}
Table Components{.link}
Configuring Tables
You can configure tables inline to an extent. Which is sometimes easier than writing a dedicated table builder.
Generally you can interact with the table criteria the same as you would with a table builder instance.
Table Builders{.link}
Table Configuration{.link}
Setting Options
You can set options by using the setOption method.
Table Options{.link}
{{ table('employment_application')
.setOption('redirect', url_previous())
.render()|raw }}