From c7cac63894263ab825dfd02c180d2efe8faf8bdc Mon Sep 17 00:00:00 2001 From: Mateja Date: Sun, 15 Nov 2020 13:04:05 +0100 Subject: Nice JSON response. --- app/Http/Controllers/ReservationsController.php | 28 ++++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/ReservationsController.php b/app/Http/Controllers/ReservationsController.php index 141dbc4..de1ea76 100644 --- a/app/Http/Controllers/ReservationsController.php +++ b/app/Http/Controllers/ReservationsController.php @@ -30,15 +30,27 @@ class ReservationsController extends Controller ]); if ($request->input('call-sign') == 'all') { - $activities = Reservation::where('approved', '1')->get(); - - return response()->json($activities); + $activities = Reservation::where('approved', '1') + ->select('operatorCall', 'fromTime', 'toTime', 'specialCall', 'frequencies', 'qso') + ->get()->toArray(); + $data = [ + 'status' => 'OK', + 'data' => $activities + ]; + + return response($data); } else { - $activities = Reservation::whereColumn('approved', '1') - ->whereColumn('specialCall', $request->input('call-sign')) - ->get(); - - return response()->json($activities); + $activities = Reservation::where('approved', '1') + ->select('operatorCall', 'fromTime', 'toTime', 'frequencies', 'qso') + ->where('specialCall', $request->input('call-sign')) + ->get() + ->toArray(); + $data = [ + 'status' => 'OK', + 'data' => $activities + ]; + + return response($data); } } else if ($request->isMethod('get')) { $signs = SpecialCall::all(); -- cgit v1.2.3