aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2020-11-01 17:03:12 +0100
committerMateja <mail@matejamaric.com>2020-11-01 17:03:12 +0100
commit0ce5bbcc443b9da12e5233a481f2ef15017ee891 (patch)
treeaebdd93295c71ba576585940a42b8fb930328fd8
parent3e5dc09d0010078568f8590daef1f95722a4dd05 (diff)
downloadyota-laravel-0ce5bbcc443b9da12e5233a481f2ef15017ee891.tar.gz
yota-laravel-0ce5bbcc443b9da12e5233a481f2ef15017ee891.zip
Callsign adding finished.
-rw-r--r--app/Http/Controllers/SpecialCallsController.php17
-rw-r--r--database/migrations/2020_10_18_183257_create_special_calls_table.php2
-rw-r--r--resources/views/pages/callsigns.blade.php22
-rw-r--r--resources/views/pages/reservations.blade.php6
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')
- <h3>Callsigns Administration:</h3>
@if (count($data) > 0)
- <div class="p-0 mr-0 mt-3 col-lg-6 table-responsive">
+ <h3>Callsigns Administration:</h3>
+ <div class="p-0 mt-3 col-lg-6 table-responsive">
<table class="table table-bordered">
@foreach ($data as $row)
<tr>
@@ -21,11 +21,19 @@
@endif
<h3 class="mt-4">Add Callsign:</h3>
+ @if (session('status'))
+ <div class="alert alert-success">
+ {{ session('status') }}
+ </div>
+ @endif
<form action="{{ route('addSignForm') }}" method="POST">
@csrf
<div class="form-group">
<label for="Sign">Special Callsign:</label>
<input type="text" name="sign" value="" id="Sign" class="form-control">
+ @error('sign')
+ <div class="alert alert-danger mt-2">{{ $message }}</div>
+ @enderror
</div>
<div class="form-group">
<label for="editor">Description:</label>
@@ -40,13 +48,9 @@
@section('scripts')
<script src="https://cdn.ckeditor.com/ckeditor5/23.1.0/classic/ckeditor.js"></script>
<script>
-ClassicEditor
- .create( document.querySelector( '#editor' ) )
- .then( editor => {
- console.log( editor );
- } )
- .catch( error => {
+ClassicEditor.create(document.querySelector('#editor'))
+ .catch(error => {
console.error( error );
- } );
+ });
</script>
@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)
<div class="table-responsive">
<table class="table table-striped table-bordered" style="white-space:nowrap;"><!-- table-hover -->
<thead class="thead-dark">
@@ -49,4 +50,9 @@
</tbody>
</table>
</div>
+@else
+<div class="text-center">
+ <strong>There are currently no reservations.</strong>
+</div>
+@endif
@endsection()