aboutsummaryrefslogtreecommitdiff
path: root/app/Http/Controllers
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2020-11-15 13:04:05 +0100
committerMateja <mail@matejamaric.com>2020-11-15 13:04:05 +0100
commitc7cac63894263ab825dfd02c180d2efe8faf8bdc (patch)
tree1eb067a2af7ab687cd660330be0339df2a34bdcd /app/Http/Controllers
parent82498e1687359b5862ed8032f9fe1da6350a8703 (diff)
downloadyota-laravel-c7cac63894263ab825dfd02c180d2efe8faf8bdc.tar.gz
yota-laravel-c7cac63894263ab825dfd02c180d2efe8faf8bdc.zip
Nice JSON response.
Diffstat (limited to 'app/Http/Controllers')
-rw-r--r--app/Http/Controllers/ReservationsController.php28
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();