From 556f242595c316b99a502b0fb217b761fcd78745 Mon Sep 17 00:00:00 2001 From: Anders Date: Tue, 18 Aug 2020 08:30:20 +0200 Subject: [PATCH] v0.10.3a - Fixed: When deleting a location you now also delete the washing machines --- skolehjem/app/Http/Controllers/LocationController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/skolehjem/app/Http/Controllers/LocationController.php b/skolehjem/app/Http/Controllers/LocationController.php index f94753e..1413352 100644 --- a/skolehjem/app/Http/Controllers/LocationController.php +++ b/skolehjem/app/Http/Controllers/LocationController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Location; +use App\WashingMachine; use Illuminate\Http\Request; use Illuminate\Http\Response; @@ -130,6 +131,10 @@ class LocationController extends Controller public function destroy($id) { $locations = Location::find($id); + + $washingMachines = WashingMachine::query()->where('location_id', '=', $id); + $washingMachines->delete(); + $locations->delete(); return redirect()->route("locations.index");