From ff775920effb30d68e5b36db7e27d7b10eb7d029 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Thu, 11 Dec 2025 19:53:57 +0700 Subject: [PATCH] feat(article): add article views column to datatable, refresh after article deletion, and correct 'Cuplikasn' typo in article form. --- app/Livewire/Datatable/Manage/ArticlesTable.php | 7 ++++++- app/Livewire/Studio/Manage/Article/Index.php | 2 ++ .../views/livewire/studio/manage/article/form.blade.php | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/Livewire/Datatable/Manage/ArticlesTable.php b/app/Livewire/Datatable/Manage/ArticlesTable.php index 03bb2ab..447715c 100644 --- a/app/Livewire/Datatable/Manage/ArticlesTable.php +++ b/app/Livewire/Datatable/Manage/ArticlesTable.php @@ -35,6 +35,11 @@ public function columns(): array ->format(fn ($value) => formatDateTime($value)) ->searchable(), + Column::make('Dilihat', 'views') + ->format(fn ($value) => currency($value)) + ->searchable() + ->sortable(), + Column::make('Aksi') ->label(function ($row) { $actions = ''; @@ -61,6 +66,6 @@ public function columns(): array public function builder(): Builder { - return Article::select('articles.id', 'author_id', 'title', 'articles.status', 'published_at')->with(['author', 'author.employee']); + return Article::select('articles.id', 'author_id', 'title', 'articles.status', 'published_at', 'views')->with(['author', 'author.employee']); } } diff --git a/app/Livewire/Studio/Manage/Article/Index.php b/app/Livewire/Studio/Manage/Article/Index.php index 062bfc9..f5fb0be 100644 --- a/app/Livewire/Studio/Manage/Article/Index.php +++ b/app/Livewire/Studio/Manage/Article/Index.php @@ -23,6 +23,8 @@ public function delete(Article $article): void $article->delete(); + $this->dispatch('refreshDatatable'); + $this->toast('Artikel berhasil dihapus.'); Flux::modals()->close(); diff --git a/resources/views/livewire/studio/manage/article/form.blade.php b/resources/views/livewire/studio/manage/article/form.blade.php index 01af824..83a0c75 100644 --- a/resources/views/livewire/studio/manage/article/form.blade.php +++ b/resources/views/livewire/studio/manage/article/form.blade.php @@ -23,7 +23,7 @@ - Cuplikasn * + Cuplikan *