File: /var/www/ipsremont-demo/app/Helpers/TableColumnsHelper.php
<?php
namespace App\Helpers;
class TableColumnsHelper
{
private array $fields = [];
public function setField(string $key, string $title, ?string $class = null, bool $sort = false, string $sortDirection = 'asc'): self
{
$this->fields[$key] = [
'field' => $key,
'displayName' => $title,
'sort' => $sort,
'sortType' => $sortDirection,
];
if (!empty($class)) {
$this->fields[$key]['class'] = $class;
}
return $this;
}
public function getColumns(): array
{
return ['fields' => $this->fields];
}
}