diff --git a/app/Livewire/Studio/Manage/Article/Create.php b/app/Livewire/Studio/Manage/Article/Create.php index 20e81cd..2ea26c7 100644 --- a/app/Livewire/Studio/Manage/Article/Create.php +++ b/app/Livewire/Studio/Manage/Article/Create.php @@ -34,11 +34,9 @@ public function save(): void ], ); - $this->dispatch('refreshDatatable'); - - $this->toast('Artikel berhasil ditambahkan.'); - - $this->redirectRoute('studio.manage.article.index'); + $this->redirectRoute('studio.manage.article.index', [ + 'notification' => 'Artikel berhasil ditambahkan.', + ], navigate: true); } public function render(): View diff --git a/app/Livewire/Studio/Manage/Article/Edit.php b/app/Livewire/Studio/Manage/Article/Edit.php index 8c84fe3..c2f373e 100644 --- a/app/Livewire/Studio/Manage/Article/Edit.php +++ b/app/Livewire/Studio/Manage/Article/Edit.php @@ -29,9 +29,9 @@ public function save(): void $this->form->update(); - $this->toast('Artikel berhasil diperbarui.'); - - $this->redirectRoute('studio.manage.article.index'); + $this->redirectRoute('studio.manage.article.index', [ + 'notification' => 'Artikel berhasil diperbarui.', + ], navigate: true); } public function render(): View diff --git a/app/Livewire/Studio/Manage/Article/Index.php b/app/Livewire/Studio/Manage/Article/Index.php index 1a0470c..c5be92d 100644 --- a/app/Livewire/Studio/Manage/Article/Index.php +++ b/app/Livewire/Studio/Manage/Article/Index.php @@ -17,6 +17,21 @@ class Index extends Component { use WithAuthorization, WithConfirmation, WithSubscribeNotification, WithToast; + public function mount(): void + { + $hasNotification = request()->get('notification'); + + if ($hasNotification) { + $this->js(<<<'JS' + const url = new URL(window.location); + url.search = ''; + window.history.replaceState({}, '', url); + JS); + + $this->toast($hasNotification); + } + } + public function delete(Article $article): void { $this->canOrAbort('delete article');