Column
The Column class is used to create columns inside a field of type table. It allows setting headers, identifiers, width, sorting, and rendering type.
Available methods:
| Method | Description |
|---|---|
label(string $label) | Sets the column header. |
id(string $id) | Sets a unique column identifier. |
render(string $render) | Defines how the data is displayed. Available values: image, boolean, button, date, color. |
format(string $format) | Applies a display format (e.g., for dates or numbers). |
sortable(bool $sortable = true) | Enables or disables sorting for this column. |
width(int $width) | Sets the column width in pixels. If not specified, the width is determined automatically. |
group(array $group) | Merges multiple columns into one group. |
withLabel(string $withLabel) | Replaces the default column header. |
renderIf(array $renderIf) | Adds a condition to show the column only if certain criteria are met. |
default(string $default) | Sets a default value if the field is empty. |
sortable
php
Column::make('name')
->label('Name')
->sortable()render date
php
Column::make('createdon')
->label('Created On')
->render('date')
->sortable()render boolean
php
Column::make('published')
->label('Published')
->render('boolean')group
php
Column::make('Colors')->group([
Column::make('Background')
->render('color')
->withLabel(),
Column::make('Color')
->width(100)
->render('color')
->withLabel('Color text'),
])renderIf
php
Column::make('Title')
->withLabel('Title / Image'),
->renderIf([
Column::make('Title'),
Column::make('Image')->render('image')
])
->default('---')