aboutsummaryrefslogtreecommitdiff
path: root/app/Http/Controllers/ReservationsController.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Http/Controllers/ReservationsController.php')
-rw-r--r--app/Http/Controllers/ReservationsController.php25
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)