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 ++++++++++++++++- ...020_10_18_183257_create_special_calls_table.php | 2 +- resources/views/pages/callsigns.blade.php | 22 +++++++++++++--------- resources/views/pages/reservations.blade.php | 6 ++++++ 4 files changed, 36 insertions(+), 11 deletions(-) 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) diff --git a/database/migrations/2020_10_18_183257_create_special_calls_table.php b/database/migrations/2020_10_18_183257_create_special_calls_table.php index 07e92be..2789eb8 100644 --- a/database/migrations/2020_10_18_183257_create_special_calls_table.php +++ b/database/migrations/2020_10_18_183257_create_special_calls_table.php @@ -16,7 +16,7 @@ class CreateSpecialCallsTable extends Migration Schema::create('special_calls', function (Blueprint $table) { $table->id(); $table->string('sign')->unique(); - $table->text('description'); + $table->text('description')->nullable(); $table->timestamps(); }); } diff --git a/resources/views/pages/callsigns.blade.php b/resources/views/pages/callsigns.blade.php index 19dc984..b4814bb 100644 --- a/resources/views/pages/callsigns.blade.php +++ b/resources/views/pages/callsigns.blade.php @@ -5,9 +5,9 @@ @section('navbar', View::make('inc.special_navbar')) @section('content') -

Callsigns Administration:

@if (count($data) > 0) -
+

Callsigns Administration:

+
@foreach ($data as $row) @@ -21,11 +21,19 @@ @endif

Add Callsign:

+ @if (session('status')) +
+ {{ session('status') }} +
+ @endif @csrf
+ @error('sign') +
{{ $message }}
+ @enderror
@@ -40,13 +48,9 @@ @section('scripts') @endsection diff --git a/resources/views/pages/reservations.blade.php b/resources/views/pages/reservations.blade.php index 9a27ee7..0d74ef3 100644 --- a/resources/views/pages/reservations.blade.php +++ b/resources/views/pages/reservations.blade.php @@ -5,6 +5,7 @@ @section('navbar', View::make('inc.special_navbar')) @section('content') +@if (count($data) > 0)
@@ -49,4 +50,9 @@
+@else +
+ There are currently no reservations. +
+@endif @endsection() -- cgit v1.2.3