searchable(),
Column::make('Judul', 'title')->searchable(),
ArrayColumn::make('Kategori')
->data(fn ($value, $row) => $row->categories->pluck('name')->toArray())
->outputFormat(fn ($index, $value) => Blade::render(''.$value.''))
->flexRow(['class' => 'gap-2 flex-wrap']),
Column::make('Status', 'status')
->format(
fn ($value) => Blade::render(''.$value->label().'')
)
->html(),
Column::make('Waktu Publish', 'published_at')
->format(fn ($value) => formatDateTimeLocalized($value))
->searchable(),
Column::make('Dilihat', 'views')
->format(fn ($value) => formatCurrencyNumber($value))
->searchable()
->sortable(),
Column::make('Aksi')
->label(function ($row) {
$actions = '';
if (auth()->user()->can('update article')) {
$actions .= view('components.actions.table.edit', [
'id' => $row->hash,
'editRoute' => route('studio.manage.article.edit', $row->hash),
])->render();
}
if (auth()->user()->can('delete article')) {
$actions .= view('components.actions.table.delete', [
'id' => $row->hash,
])->render();
}
return $actions;
})
->html()
->hideIf(auth()->user()->cannot('update article') && auth()->user()->cannot('delete article')),
];
}
public function builder(): Builder
{
return Article::select('articles.id', 'author_id', 'title', 'articles.status', 'published_at', 'views')->with(['author', 'author.employee', 'categories']);
}
}