From 0ce5bbcc443b9da12e5233a481f2ef15017ee891 Mon Sep 17 00:00:00 2001 From: Mateja Date: Sun, 1 Nov 2020 17:03:12 +0100 Subject: Callsign adding finished. --- app/Http/Controllers/SpecialCallsController.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'app/Http') diff --git a/app/Http/Controllers/SpecialCallsController.php b/app/Http/Controllers/SpecialCallsController.php index 72da6b9..073bf6e 100644 --- a/app/Http/Controllers/SpecialCallsController.php +++ b/app/Http/Controllers/SpecialCallsController.php @@ -103,7 +103,22 @@ class SpecialCallsController extends Controller public function addForm(Request $request) { - return Redirect::back(); + $rules = [ 'sign' => 'required' ]; + $messages = [ 'sign.required' => 'You need to provide a callsign!' ]; + $validator = Validator::make($request->all(), $rules, $messages); + + if ($validator->fails()) { + return Redirect::back() + ->withErrors($validator) + ->withInput(); + } + + $newcall = new SpecialCall(); + $newcall->sign = strtoupper($request->sign); + $newcall->description = $request->description; + $newcall->saveOrFail(); + + return Redirect::back()->with('status', 'Callsign added.'); } public function reservations(Request $request) -- cgit v1.2.3