Customization

The Streams module uses sane defaults for all UI components. Form fields will display in the order of their assignments. Tables will display the first 4 field values as columns, again in order of field assignment.

A fundamental idea to keep in mind when customizing is that streams generated within the Streams module are exactly the same as any other stream in the system. They generated a model, have a namespace, stream slug, fields, assignments, etc.

Customization Basics

You can easily customize the UI for streams entries by defining configuration files for the Streams module.

For example if your namespace slug is staff then the configuration file would be named staff.php.

You can publish the Streams module with php artisan addon:publish anomaly.module.streams and add the configuration file to the published configuration directory or simply create the file in the override directory without publishing: /resources/{REF}/addons/anomaly/streams-module/config/staff.php.

The basic structure of the configuration file is separated into streams by stream slug.

Below is an example staff.php control panel configuration file that customizes the form and table for the members stream:

<?php

return [
    'members' => [ // Stream Slug
        'table' => [ // UI Type
            'filters' => [ // Component
                'search' => [
                    'first_name',
                    'last_name',
                    'bio',
                    'phone',
                    'email',
                ],
                'department',
            ],
            'columns' => [ // Component
                'name' => [
                    'wrapper' => '{value.first} {value.last}',
                    'value'   => [
                        'first' => 'first_name',
                        'last'  => 'last_name',
                    ],
                ],
                'entry.phone.tel|raw',
                'entry.email.mailto|raw',
            ],
        ],
        'form'  => [ // UI Type
            'sections' => [ // Component
                'member' => [
                    'tabs' => [
                        'general' => [
                            'title'  => 'General',
                            'fields' => [
                                'first_name',
                                'last_name',
                                'department',
                                'bio',
                            ],
                        ],
                        'contact' => [
                            'title'  => 'Contact',
                            'fields' => [
                                'phone',
                                'email',
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],
];

Tables

You can customize entry tables by defining your own table class:

<?php

return [
    'members' => [ // Stream Slug
        'table' => 'App\Example\MyTableBuilder',
    ],
];

You can also define component definitions like you would in the table builder itself. Note you can still use handler classes by defining them as we do actions in the below example:

<?php

return [
    'members' => [ // Stream Slug
        'table' => [ // UI Type
            'filters' => [ // Component
                'search' => [
                    'first_name',
                    'last_name',
                    'bio',
                    'phone',
                    'email',
                ],
                'department',
            ],
            'columns' => [ // Component
                'name' => [
                    'wrapper' => '{value.first} {value.last}',
                    'value'   => [
                        'first' => 'first_name',
                        'last'  => 'last_name',
                    ],
                ],
                'entry.phone.tel|raw',
                'entry.email.mailto|raw',
            ],
            'actions' => 'App\Example\ActionsHandler@handle',
        ],
    ],
];

Forms

You can customize entry forms by defining your own form class:

<?php

return [
    'members' => [ // Stream Slug
        'form' => 'App\Example\MyFormBuilder',
    ],
];

You can also define component definitions like you would in the table builder itself. Note you can still use handler classes by defining them as we do actions in the below example:

<?php

return [
    'members' => [ // Stream Slug
        'form'  => [ // UI Type
            'sections' => [ // Component
                'member' => [
                    'tabs' => [
                        'general' => [
                            'title'  => 'General',
                            'fields' => [
                                'first_name',
                                'last_name',
                                'department',
                                'bio',
                            ],
                        ],
                        'contact' => [
                            'title'  => 'Contact',
                            'fields' => [
                                'phone',
                                'email',
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],
];

Control Panel Sections

You can customize individual module sections by defining cp.sections for the stream. This is not typically needed but can be helpful when more advance UI is desired.

<?php

return [
    'members'  => [ // Stream Slug 
        'cp' => [ '// UI Type
            'section' => [
                'buttons' => [
                    'new_member'    => [
                        'data-toggle' => 'modal',
                        'data-target' => '#modal',
                        'href'        => 'admin/some/custom/route/choose_type',
                    ],
                ],
            ],
        ],
    ],
];

Resources

Overriding Streams Module Entry Tables - Joining and Filtering{.link}