searchable(), ImageColumn::make('Gambar') ->location(fn ($row) => optional($row->getMedia('image')->first())->getUrl() ?? asset('assets/images/logo.png')) ->attributes(fn ($row) => [ 'style' => 'width: 50px; height: 50px;', 'alt' => $row->name, ]), Column::make('Aksi') ->label(function ($row) { $actions = ''; $maxSortOrder = Brand::max('sort_order'); if (auth()->user()->can('update brand')) { if ($row->sort_order > 1) { $actions .= view('components.actions.table.sort-button', [ 'id' => $row->hash, 'module' => 'brand', 'direction' => 'up', 'tooltip' => 'Naik', 'color' => 'cyan', 'icon' => 'arrow-up', ])->render(); $actions .= view('components.actions.table.sort-button', [ 'id' => $row->hash, 'module' => 'brand', 'direction' => 'first', 'tooltip' => 'Pertama', 'color' => 'emerald', 'icon' => 'bars-arrow-up', ])->render(); } if ($row->sort_order < $maxSortOrder) { $actions .= view('components.actions.table.sort-button', [ 'id' => $row->hash, 'module' => 'brand', 'direction' => 'down', 'tooltip' => 'Turun', 'color' => 'orange', 'icon' => 'arrow-down', ])->render(); $actions .= view('components.actions.table.sort-button', [ 'id' => $row->hash, 'module' => 'brand', 'direction' => 'last', 'tooltip' => 'Terakhir', 'color' => 'rose', 'icon' => 'bars-arrow-down', ])->render(); } } if (auth()->user()->can('update brand')) { $actions .= view('components.actions.table.edit-modal', [ 'id' => $row->hash, 'method' => 'update', 'modalTitle' => 'Ubah Merek', ])->render(); } if (auth()->user()->can('delete brand')) { $actions .= view('components.actions.table.delete', [ 'id' => $row->hash, ])->render(); } return $actions; }) ->html() ->hideIf(auth()->user()->cannot('update brand') && auth()->user()->cannot('delete brand')), ]; } public function builder(): Builder { return Brand::select('id', 'name', 'sort_order')->orderBy('sort_order'); } }