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 Table Builders

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

Table Components

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

Table Configuration

Setting Options

You can set options by using the setOption method.

Table Options

{{ table('employment_application')
    .setOption('redirect', url_previous())
    .render()|raw }}