Revo Docs
v16.0.1

Fields

Fields are the basic component of any thrust Resource, they are what defines what can be edited, and displayed and they all share a few methods.

You need to return an array of fields in the fields method of your resource. Each field is an instance of a class that extends Field class.
Almost all field method return the field instance itself, so you can chain them, making it very readable.

public function fields()
{
    return [
        Integer::make('id'),
        Text::make('name'),
    ];
}
Copied!

To create a field we will use the make method, where the first parameter is the name of the field and the second is the label that will be displayed in the UI.

Index / Edit

Thrust comes with mainly two views, the index where it displays a list of the resource models and the edit where you can edit its properties. You can define where the field is show using the onlyInIndex or onlyInEdit methods.

There is also the hide or show methods to completely show or hide a field. It can be useful when it depends on some other global variable.

Another handy method is to display a field on the index page depending on the size of the window, you achieve this using the displayFrom with a tailwind screen size.

Text::make('name')->onlyInIndex()->displayFrom('md')
Copied!

There is also the convenience method withoutIndexHeader that will hide the title in the index page. This is useful for fields that display a self explanatory icon.

Rules

One of the main features of fields is the ability to define rules for them. You can define rules the same way you would using Laravel's validation rules . Those rules will apply on the create and update .

Text::make('name')->rules('required|min:3|unique:posts')
Copied!

Global Search

By default all Thrust fields will be included in the global search. If you want to exclude a field from the global search you can use the withoutGlobalSearch method. Learn more about the Global search .

Importable

As well as the global search, fields by default are importable. If you want to exclude a field from the import you can use the importable(false) method. Learn more about the Import .

Sortable

Thrust allows the index table to be sorted by any field, you simply need to call the sortable() method on the field.
You can define if should sort ascending or descending using the asc or desc as the second parameter.

Text::make('name')->sortable(true, 'asc')
Copied!

Description

Some fields, might require a description to tell the user what the field is about. You can define a description using the withDesc method.
This description will be shown in the edit modal. By default it will use the fieldDesc translation key in the config/thrust.php translationsPrefix file, but you want to use a different one you can pass it as the second parameter.

Text::make('name')->withDesc(true, __('the description'))
Copied!

Tooltip

Sometimes you might want to show a tooltip on a field. You can define a tooltip using the tooltip method.
This will be displayed on the index list header.

Text::make('name')->tooltip(__('the tooltip'))
Copied!