/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $perbaikan = Perbaikan::find($id); if (!$perbaikan) { return "Not Found"; } $now = Carbon::now()->addHours(7)->toDateTimeString(); $curDateTime = strtotime($now); $mulai = strtotime($perbaikan->waktu_booking_mulai); $selesai = strtotime($perbaikan->waktu_booking_selesai); if ($curDateTime > $mulai && $curDateTime < $selesai) { return "Tidak dapat menghapus"; } else { $perbaikan->delete(); return 1; } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $peralatan = Peralatan::find($id); if (!$peralatan) { return "Not Found"; } $inBooking = Booking::where('id_barang', '=', $id)->count(); $inTransaksi = Transaksi::where('id_barang', '=', $id)->count(); $inPerbaakan = Perbaikan::where('id_barang', '=', $id)->count(); if ($inBooking > 0 || $inTransaksi > 0 || $inPerbaakan > 0) { return "Tidak dapat menghapus"; } else { $peralatan->delete(); return 1; } }