diff options
author | Mateja <mail@matejamaric.com> | 2020-11-16 20:15:43 +0100 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2020-11-16 20:15:43 +0100 |
commit | 26bdfee839f4b8fb18beb1a9770fc758ad20c267 (patch) | |
tree | 1b928e64a2eab9f97f60d8ac1011fac379af71b5 /app/Http/Controllers | |
parent | 03616b700748fe4e44eea484a4d7679121517791 (diff) | |
download | yota-laravel-26bdfee839f4b8fb18beb1a9770fc758ad20c267.tar.gz yota-laravel-26bdfee839f4b8fb18beb1a9770fc758ad20c267.zip |
AJAX filtering reservations on admin panel...
Diffstat (limited to 'app/Http/Controllers')
-rw-r--r-- | app/Http/Controllers/ReservationsController.php | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/app/Http/Controllers/ReservationsController.php b/app/Http/Controllers/ReservationsController.php index b347409..2a46343 100644 --- a/app/Http/Controllers/ReservationsController.php +++ b/app/Http/Controllers/ReservationsController.php @@ -128,8 +128,41 @@ class ReservationsController extends Controller // Administration public function edit(Request $request) { - $data = Reservation::orderBy('id', 'desc')->get(); - return view('pages.reservations', compact('data')); + if ($request->isMethod('post')) { + + $request->validate([ + 'call-sign' => 'required|alphanum' + ]); + + if ($request->input('call-sign') == 'all') { + $activities = Reservation::orderBy('id', 'desc') + ->get() + ->toArray(); + $data = [ + 'status' => 'OK', + 'data' => $activities + ]; + + return response($data); + } else { + $activities = Reservation::where('specialCall', $request->input('call-sign')) + ->orderBy('id', 'desc') + ->get() + ->toArray(); + $data = [ + 'status' => 'OK', + 'data' => $activities + ]; + + return response($data); + } + + } + else { + //$data = Reservation::orderBy('id', 'desc')->get(); + $signs = SpecialCall::all(); + return view('pages.reservations', compact('signs')); + } } public function update(Request $request) |