Merge branch 'master' of https://github.com/sebathefox/skolehjem-webapp into master
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Location;
|
||||
use App\WashingMachine;
|
||||
use App\WashingReservation;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
@@ -130,12 +131,21 @@ class LocationController extends Controller
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$locations = Location::find($id);
|
||||
$location = Location::find($id);
|
||||
$washingMachines = WashingMachine::query()->where('location_id', '=', $id)->get();
|
||||
|
||||
$washingMachines = WashingMachine::query()->where('location_id', '=', $id);
|
||||
$washingMachines->delete();
|
||||
foreach ($washingMachines as $machine) {
|
||||
$washingReservations = WashingReservation::query()->where('machine_id', '=', $machine->id)->get();
|
||||
|
||||
$locations->delete();
|
||||
foreach ($washingReservations as $reservation)
|
||||
{
|
||||
$reservation->delete();
|
||||
}
|
||||
|
||||
$machine->delete();
|
||||
}
|
||||
|
||||
$location->delete();
|
||||
|
||||
return redirect()->route("locations.index");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user