/** * 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; } }