> For the complete documentation index, see [llms.txt](https://web-vovan.gitbook.io/rock-cms/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://web-vovan.gitbook.io/rock-cms/ispolzovanie/vyvod-spiska-resursov/kolonki.md).

# Колонки

Rock.Cms поддерживает несколько типов колонок для вывода в списке ресурсов.

Колонки добавляются в методе columns.

```php
public function columns(): array
{
    return [
        SelectColumn::make($this)
            ->addClass('text-center'),
        Column::make('id', 'ID')
            ->sortable(),
        EditLinkColumn::make('title', 'Заголовок')
            ->sortable(),
        ActiveColumn::make('active', 'Активность')
            ->addClass('text-center')
            ->sortable(),
        Column::make('created_at', 'Дата'),
        ActionColumn::make('Действия')
            ->addClass('text-center'),
    ];
}
```

### Типы колонок

#### Простой текст

Данный тип выводит без форматирования поле Eloquent модели.

```php
use WebVovan\RockCms\View\Components\Column;
...

Column::make('id', 'ID')
```

#### Ссылка на редактирования ресурса

Данный тип оборачивает поле Eloquent модели в ссылку, которая ведет на страницу редактирования ресурса.

```php
use WebVovan\RockCms\View\Components\EditLinkColumn;
...

EditLinkColumn::make('title', 'Заголовок'
```

#### Иконка активности

Данный тип показывает иконки активности в зависимости от булева значения поля Eloquent модели.

```php
use WebVovan\RockCms\View\Components\ActiveColumn;
...

ActiveColumn::make('active', 'Активность')
```

#### Выбор списка ресурсов

Данный тип добавляет чекбоксы для выбора нескольких ресурсов в списке для их одновременного удаления.

```php
use WebVovan\RockCms\View\Components\SelectColumn;
...

SelectColumn::make($this)
```

#### Действия над ресурсом

Данный тип выводит кнопки для удаления, просмотра и редактирования ресурса.

```php
use WebVovan\RockCms\View\Components\ActionColumn;
...

ActionColumn::make('Действия')
```

По умолчанию выводятся кнопки для редактирования и удаления.

Управлять показом кнопок можно с помощью свойств:

```php
class PostList extends ResourceListComponent
{
    // Класс ресурса
    public string $resourceClass = Post::class;

    // Кнопка редактирования ресурса
    public bool $activeEditButton = true;
    
    // Кнопка удаления ресурса
    public bool $activeDeleteButton = false;
    
    // Кнопка просмотра ресурса
    public bool $activeShowButton = true;
    
    ...
}
```

#### Замена текста

Заменяет текст из поля на другое значение

```php
ReplaceColumn::make('author', 'Автор')
    ->setReplaceItems([
        'admin' => 'Администратор',
        'manager' => 'Менеджер',
    ])
```

### Дополнительные возможности

Для каждой колонки в таблице можно добавить возможность сортировки, вызвав метод sortable.

```php
EditLinkColumn::make('title', 'Заголовок')->sortable(),
```

Для добавления пользовательского класса используйте метод addClass.

```php
ActionColumn::make('Действия')->addClass('text-center'),
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://web-vovan.gitbook.io/rock-cms/ispolzovanie/vyvod-spiska-resursov/kolonki.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
