diff options
author | Mateja <mail@matejamaric.com> | 2020-11-15 13:04:05 +0100 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2020-11-15 13:04:05 +0100 |
commit | c7cac63894263ab825dfd02c180d2efe8faf8bdc (patch) | |
tree | 1eb067a2af7ab687cd660330be0339df2a34bdcd /app/Http | |
parent | 82498e1687359b5862ed8032f9fe1da6350a8703 (diff) | |
download | yota-laravel-c7cac63894263ab825dfd02c180d2efe8faf8bdc.tar.gz yota-laravel-c7cac63894263ab825dfd02c180d2efe8faf8bdc.zip |
Nice JSON response.
Diffstat (limited to 'app/Http')
-rw-r--r-- | app/Http/Controllers/ReservationsController.php | 28 |
1 files 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(); |