Fixed redirect

This commit is contained in:
frederikpyt 2020-07-01 11:54:33 +02:00
parent b84b9dbe04
commit cd828725b6
2 changed files with 27 additions and 8 deletions

View File

@ -59,9 +59,14 @@ class WashingMachineController extends Controller
]); ]);
$machine = new WashingMachine($data); $machine = new WashingMachine($data);
$machine->save(); $saved = $machine->save();
return Response::detect("washing-machines.store"); if(!$saved){
return Response::detect("washing-machines.store");
}else{
$machines = WashingMachine::query()->paginate($request->input("limit", 20));
return Response::detect("washing-machines.index", ['machines' => $machines]);
}
} }
/** /**
@ -117,7 +122,7 @@ class WashingMachineController extends Controller
return Response::detect("washing-machines.update", [ return Response::detect("washing-machines.update", [
"machine" => $machine "machine" => $machine
]); ]);
}else{ } else {
$machines = WashingMachine::query()->paginate($request->input("limit", 20)); $machines = WashingMachine::query()->paginate($request->input("limit", 20));
return Response::detect("washing-machines.index", [ return Response::detect("washing-machines.index", [
"machines" => $machines "machines" => $machines

View File

@ -65,7 +65,16 @@ class WashingReservationController extends Controller
$machineReservation = new WashingReservation($data); $machineReservation = new WashingReservation($data);
$machineReservation->save(); $machineReservation->save();
return Response::detect("washing-reservations.store"); $saved = $machineReservation->save();
if(!$saved){
return Response::detect("washing-reservations.store", [
"washing_reservation" => $machineReservation
]);
}else{
$reservations = WashingReservation::query()->paginate($request->input("limit", 20));
return Response::detect("washing-machines.index", ['reservations' => $reservations]);
}
} }
/** /**
@ -115,11 +124,16 @@ class WashingReservationController extends Controller
$machineReservation->update($data); $machineReservation->update($data);
$machineReservation->save(); $saved = $machineReservation->save();
return Response::detect("washing-reservations.update", [ if(!$saved){
"washing_reservation" => $machineReservation return Response::detect("washing-reservations.update", [
]); "washing_reservation" => $machineReservation
]);
}else{
$reservations = WashingReservation::query()->paginate($request->input("limit", 20));
return Response::detect("washing-machines.index", ['reservations' => $reservations]);
}
} }
/** /**