diff options
author | Mateja <mail@matejamaric.com> | 2020-11-13 01:47:38 +0100 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2020-11-13 01:47:38 +0100 |
commit | cddef1ffc9cb204d87299cea7e9f2de0cf6e58c3 (patch) | |
tree | a35436b5e59a28a2b03bd77750368e9f30fdfc5f /app | |
parent | 470a54a8c6e92416a8245af0bc87170ad934fae0 (diff) | |
download | yota-laravel-cddef1ffc9cb204d87299cea7e9f2de0cf6e58c3.tar.gz yota-laravel-cddef1ffc9cb204d87299cea7e9f2de0cf6e58c3.zip |
Work on activities...
Diffstat (limited to 'app')
-rw-r--r-- | app/Http/Controllers/ReservationsController.php | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/app/Http/Controllers/ReservationsController.php b/app/Http/Controllers/ReservationsController.php index d3b141e..141dbc4 100644 --- a/app/Http/Controllers/ReservationsController.php +++ b/app/Http/Controllers/ReservationsController.php @@ -11,20 +11,39 @@ use Illuminate\Support\Facades\Redirect; use App\Models\Reservation; use App\Models\SpecialCall; +use function response; class ReservationsController extends Controller { public function index(Request $request) { - $activities = Reservation::where('approved', '1')->get(); //$activities = Reservation::addSelect([ //'specialCall' => SpecialCall::select('sign') ////->whereColumn('reservations.specialCall', 'special_calls.id') //->whereColumn('specialCall', 'id') //->limit(1) //])->get(); - - return view('pages.activities', compact('activities')); + if ($request->isMethod('post')) { + + $request->validate([ + 'call-sign' => 'required|alphanum' + ]); + + if ($request->input('call-sign') == 'all') { + $activities = Reservation::where('approved', '1')->get(); + + return response()->json($activities); + } else { + $activities = Reservation::whereColumn('approved', '1') + ->whereColumn('specialCall', $request->input('call-sign')) + ->get(); + + return response()->json($activities); + } + } else if ($request->isMethod('get')) { + $signs = SpecialCall::all(); + return view('pages.activities', compact('signs')); + } } public function create(Request $request) |