@foreach ($columns as $col) @php $isSortable = $col['sortable'] ?? false; $fieldForSort = $col['sortField'] ?? $col['field']; @endphp @endforeach
Učitavam...
@forelse($rows as $row) @foreach ($columns as $col) @php // čitanje vrednosti (podržano dot-notation: relation.field) $value = data_get($row, $col['field']); // tip formatiranja $type = $col['type'] ?? 'text'; @endphp @endforeach @empty @endforelse
@if ($isSortable) {{-- @if ($sortField === $fieldForSort) @endif --}} @else {{ $col['label'] }} @endif
@switch($type) @case('date') {{ $value ? \Carbon\Carbon::parse($value)->format($col['format'] ?? 'd.m.Y. (H:i)') : '/' }} @break @case('money') {{ $value !== null ? number_format($value, $col['decimals'] ?? 2, '.', ',') . ' ' . ($col['suffix'] ?? 'rsd') : '/' }} @break @case('badge') @php $map = $col['map'] ?? []; // npr. [0 => ['Neaktivan','text-danger'], 1 => ['Aktivan','text-success']] $pair = $map[$value] ?? null; @endphp @if ($pair) {{ $pair[0] ?? $value }} @else {{ $value }} @endif @break @case('link') @php // generiši route parametre iz polja reda $route = $col['route'] ?? null; $paramsMap = $col['route_params'] ?? []; // ['company_bought_package_id' => 'company_bought_package_id', 'invoice_id' => 'invoice_id'] $params = []; foreach ($paramsMap as $k => $fieldPath) { $params[$k] = data_get($row, $fieldPath); } @endphp @if ($route) {{ $value }} @else {{ $value }} @endif @break @default {{ $value ?? '/' }} @endswitch
Nema podataka.
{{ $rows->links('vendor.livewire.admin-pagination') }}