diff --git a/.ai/CONVENTIONS.md b/.ai/CONVENTIONS.md index 882c83c..7939f67 100644 --- a/.ai/CONVENTIONS.md +++ b/.ai/CONVENTIONS.md @@ -503,9 +503,7 @@ ### ZONK — Tidak Ada Logic di Controller { $this->service->store($request->validated()); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil ditambahkan']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil ditambahkan'])->back(); } } @@ -518,9 +516,7 @@ ### ZONK — Tidak Ada Logic di Controller { $this->service->resetPassword($user, $request->validated()); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Password berhasil direset']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Password berhasil direset'])->back(); } ``` @@ -565,9 +561,7 @@ ### Return ke Halaman yang Sama — Gunakan `back()` { $this->service->destroy($product); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil dihapus']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil dihapus'])->back(); } // ❌ JANGAN pakai ->with() @@ -622,9 +616,7 @@ ### DB Transaction — Gunakan `handleAction()` untuk 2+ Query { $this->service->destroy($product); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil dihapus']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil dihapus'])->back(); } ``` diff --git a/app/Http/Controllers/Admin/AdminSettingsController.php b/app/Http/Controllers/Admin/AdminSettingsController.php index d43154e..c51b170 100644 --- a/app/Http/Controllers/Admin/AdminSettingsController.php +++ b/app/Http/Controllers/Admin/AdminSettingsController.php @@ -32,35 +32,27 @@ public function updateSystem(UpdateSystemRequest $request): RedirectResponse { $this->service->updateSystem($request->validated()); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan sistem berhasil diperbarui.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan sistem berhasil diperbarui.'])->back(); } public function updateHomepage(UpdateHomepageRequest $request): RedirectResponse { $this->service->updateHomepage($request->validated()); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan homepage berhasil diperbarui.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan homepage berhasil diperbarui.'])->back(); } public function updateSocialMedia(UpdateSocialMediaRequest $request): RedirectResponse { $this->service->updateSocialMedia($request->validated()); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan media sosial berhasil diperbarui.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan media sosial berhasil diperbarui.'])->back(); } public function updateHR(UpdateHRRequest $request): RedirectResponse { $this->service->updateHR($request->validated()); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan HR berhasil diperbarui.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan HR berhasil diperbarui.'])->back(); } } diff --git a/app/Http/Controllers/Admin/HR/EmployeeController.php b/app/Http/Controllers/Admin/HR/EmployeeController.php index dca788e..5432916 100644 --- a/app/Http/Controllers/Admin/HR/EmployeeController.php +++ b/app/Http/Controllers/Admin/HR/EmployeeController.php @@ -86,9 +86,7 @@ public function toggleActive(User $user): RedirectResponse $employee = $this->service->toggleActive($user); $status = $employee->is_active ? 'diaktifkan' : 'dinonaktifkan'; - Inertia::flash('toast', ['type' => 'success', 'message' => "Pegawai berhasil {$status}."]); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => "Pegawai berhasil {$status}."])->back(); } public function resetPassword(User $user): RedirectResponse diff --git a/app/Http/Controllers/Admin/Master/CategoryController.php b/app/Http/Controllers/Admin/Master/CategoryController.php index f8e1c52..491da52 100644 --- a/app/Http/Controllers/Admin/Master/CategoryController.php +++ b/app/Http/Controllers/Admin/Master/CategoryController.php @@ -28,26 +28,20 @@ public function store(CategoryRequest $request): RedirectResponse { $this->service->store($request->validated()); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Kategori berhasil ditambahkan.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Kategori berhasil ditambahkan.'])->back(); } public function update(CategoryRequest $request, Category $category): RedirectResponse { $this->service->update($category, $request->validated()); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Kategori berhasil diperbarui.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Kategori berhasil diperbarui.'])->back(); } public function destroy(Category $category): RedirectResponse { $this->service->destroy($category); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Kategori berhasil dihapus.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Kategori berhasil dihapus.'])->back(); } } diff --git a/app/Http/Controllers/Admin/Master/CustomerController.php b/app/Http/Controllers/Admin/Master/CustomerController.php index 0d1cffa..a9d1b11 100644 --- a/app/Http/Controllers/Admin/Master/CustomerController.php +++ b/app/Http/Controllers/Admin/Master/CustomerController.php @@ -28,26 +28,20 @@ public function store(CustomerRequest $request): RedirectResponse { $this->service->store($request->validated()); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Customer berhasil ditambahkan.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Customer berhasil ditambahkan.'])->back(); } public function update(CustomerRequest $request, Customer $customer): RedirectResponse { $this->service->update($customer, $request->validated()); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Customer berhasil diperbarui.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Customer berhasil diperbarui.'])->back(); } public function destroy(Customer $customer): RedirectResponse { $this->service->destroy($customer); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Customer berhasil dihapus.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Customer berhasil dihapus.'])->back(); } } diff --git a/app/Http/Controllers/Admin/Master/Product/ProductController.php b/app/Http/Controllers/Admin/Master/Product/ProductController.php index 48c6e69..9a4970f 100644 --- a/app/Http/Controllers/Admin/Master/Product/ProductController.php +++ b/app/Http/Controllers/Admin/Master/Product/ProductController.php @@ -84,9 +84,7 @@ public function toggleStatus(Product $product): RedirectResponse $this->service->toggleStatus($product); $status = $product->fresh()->status; - Inertia::flash('toast', ['type' => 'success', 'message' => "Status produk berhasil diubah menjadi {$status->label()}."]); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => "Status produk berhasil diubah menjadi {$status->label()}."])->back(); } public function toggleFeatured(Product $product): RedirectResponse @@ -94,18 +92,14 @@ public function toggleFeatured(Product $product): RedirectResponse $this->service->toggleFeatured($product); $featured = $product->fresh()->is_featured; - Inertia::flash('toast', ['type' => 'success', 'message' => $featured ? 'Produk berhasil ditampilkan di halaman depan.' : 'Produk berhasil disembunyikan dari halaman depan.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => $featured ? 'Produk berhasil ditampilkan di halaman depan.' : 'Produk berhasil disembunyikan dari halaman depan.'])->back(); } public function approve(Product $product): RedirectResponse { $this->service->approve($product); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil disetujui.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil disetujui.'])->back(); } public function reject(Product $product): RedirectResponse @@ -113,18 +107,14 @@ public function reject(Product $product): RedirectResponse $reason = request()->input('rejection_reason', ''); $this->service->reject($product, $reason); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil ditolak.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil ditolak.'])->back(); } public function resubmit(Product $product): RedirectResponse { $this->service->resubmit($product); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil diajukan ulang.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil diajukan ulang.'])->back(); } public function variants(Product $product): JsonResponse diff --git a/app/Http/Controllers/Admin/Master/RawMaterial/RawMaterialController.php b/app/Http/Controllers/Admin/Master/RawMaterial/RawMaterialController.php index 6a91c64..5dae361 100644 --- a/app/Http/Controllers/Admin/Master/RawMaterial/RawMaterialController.php +++ b/app/Http/Controllers/Admin/Master/RawMaterial/RawMaterialController.php @@ -81,9 +81,7 @@ public function toggleStatus(RawMaterial $rawMaterial): RedirectResponse $this->service->toggleStatus($rawMaterial); $status = $rawMaterial->fresh()->is_active ? 'Aktif' : 'Non Aktif'; - Inertia::flash('toast', ['type' => 'success', 'message' => "Status bahan baku berhasil diubah menjadi {$status}."]); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => "Status bahan baku berhasil diubah menjadi {$status}."])->back(); } public function variants(RawMaterial $rawMaterial): JsonResponse diff --git a/app/Http/Controllers/Admin/Master/SupplierController.php b/app/Http/Controllers/Admin/Master/SupplierController.php index 25ea23e..d4c3aa6 100644 --- a/app/Http/Controllers/Admin/Master/SupplierController.php +++ b/app/Http/Controllers/Admin/Master/SupplierController.php @@ -28,26 +28,20 @@ public function store(SupplierRequest $request): RedirectResponse { $this->service->store($request->validated()); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Supplier berhasil ditambahkan.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Supplier berhasil ditambahkan.'])->back(); } public function update(SupplierRequest $request, Supplier $supplier): RedirectResponse { $this->service->update($supplier, $request->validated()); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Supplier berhasil diperbarui.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Supplier berhasil diperbarui.'])->back(); } public function destroy(Supplier $supplier): RedirectResponse { $this->service->destroy($supplier); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Supplier berhasil dihapus.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Supplier berhasil dihapus.'])->back(); } } diff --git a/app/Http/Controllers/Admin/RoleController.php b/app/Http/Controllers/Admin/RoleController.php index c02fa62..c1326aa 100644 --- a/app/Http/Controllers/Admin/RoleController.php +++ b/app/Http/Controllers/Admin/RoleController.php @@ -61,8 +61,6 @@ public function destroy(Role $role): RedirectResponse { $this->service->destroy($role); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Role berhasil dihapus.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Role berhasil dihapus.'])->back(); } } diff --git a/app/Http/Controllers/Settings/SecurityController.php b/app/Http/Controllers/Settings/SecurityController.php index f6233fd..fd4c47a 100644 --- a/app/Http/Controllers/Settings/SecurityController.php +++ b/app/Http/Controllers/Settings/SecurityController.php @@ -22,8 +22,6 @@ public function update(PasswordUpdateRequest $request): RedirectResponse { $request->user()->update(['password' => $request->password]); - Inertia::flash('toast', ['type' => 'success', 'message' => 'Kata sandi berhasil diperbarui.']); - - return back(); + return Inertia::flash('toast', ['type' => 'success', 'message' => 'Kata sandi berhasil diperbarui.'])->back(); } }