diff --git a/app/Http/Controllers/Admin/BuketController.php b/app/Http/Controllers/Admin/BuketController.php index 0c82347..5dc07f7 100755 --- a/app/Http/Controllers/Admin/BuketController.php +++ b/app/Http/Controllers/Admin/BuketController.php @@ -122,7 +122,7 @@ public function update(Request $request, string $id) if ($request->hasFile('foto')) { // 1. Hapus foto lama jika ada - if ($buket->foto && file_exists(public_path($buket->foto))) { + if ($buket->foto) { File::delete(public_path($buket->foto)); } @@ -142,7 +142,7 @@ public function destroy(string $id) { $buket = Buket::findOrFail($id); - if ($buket->foto && File::exists(public_path($buket->foto))) { + if ($buket->foto) { File::delete(public_path($buket->foto)); } $buket->delete(); diff --git a/app/Http/Controllers/Admin/FotoController.php b/app/Http/Controllers/Admin/FotoController.php index 9238c40..67ffa7a 100755 --- a/app/Http/Controllers/Admin/FotoController.php +++ b/app/Http/Controllers/Admin/FotoController.php @@ -29,7 +29,7 @@ public function store(Request $request) $validator = Validator::make($request->all(), [ 'nama' => 'required|string|min:3|max:100', 'harga' => 'required|numeric|min:0', - 'durasi' => 'required|integer|min:1', + 'durasi' => 'required|integer|min:0', 'deskripsi' => 'required|string|min:10', 'foto' => 'required|image|mimes:jpeg,png,jpg|max:2048', ], [ @@ -84,7 +84,7 @@ public function update(Request $request, string $id) $validator = Validator::make($request->all(), [ 'nama' => 'required|string|min:3|max:100', 'harga' => 'required|numeric|min:0', - 'durasi' => 'required|integer|min:1', + 'durasi' => 'required|integer|min:0', 'deskripsi' => 'required|string|min:10', 'foto' => 'nullable|image|mimes:jpeg,png,jpg|max:2048', ], [ @@ -115,7 +115,7 @@ public function update(Request $request, string $id) if ($request->hasFile('foto')) { // Hapus file lama jika ada foto baru yang diunggah - if ($paket->foto && File::exists(public_path($paket->foto))) { + if ($paket->foto) { File::delete(public_path($paket->foto)); } @@ -136,7 +136,7 @@ public function destroy(string $id) $paket = PaketFoto::where('id_paket', $id)->firstOrFail(); // 1. Cek dan hapus file foto dari folder public - if ($paket->foto && File::exists(public_path($paket->foto))) { + if ($paket->foto) { File::delete(public_path($paket->foto)); }