Columns

Setting Columns

You can define your columns in your CRUD Config.

$this->columns([
    (new Text('name')),
]);

Available column types

  • Text
  • TextLink

Formatting

You can format the output in a column.

(new Text('amount_paid'))
    ->setFormatter(function ($amount) {
        setLocale(LC_MONETARY, 'en_GB.UTF-8');
        return money_format('%n', $amount / 100);
    }),

Labeling

You can rename the column headings

(new Text('some_nasty_long_column_name'))
    ->setLabel('Nice Title'),

TextLink Columns

To use a TextLink column you will need to create an attribute on your model that provides the text of the link and its URL.

# app\Post.php
public function getTitleColumnAttribute()
{
    return [
        'text' => $this->title,
        'url'  => route('admin.posts.edit', $this->id),
    ];
}

Then provide the name of this attribute to the TextLink.

TextLink::make('title_column'),