From 11c724649cea55fdaadc46f891bf9956ddd9bc39 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Sun, 31 Dec 2017 14:20:52 -0600 Subject: [PATCH] Field and error message cleanup --- .../Controllers/Admin/FlightController.php | 2 +- .../Admin/PirepFieldController.php | 22 ++--- app/Models/Acars.php | 6 +- app/Models/Aircraft.php | 2 - app/Models/Airline.php | 25 +++++- app/Models/Airport.php | 10 +-- app/Models/Setting.php | 1 - .../views/admin/aircraft/fields.blade.php | 2 +- .../views/admin/airlines/fields.blade.php | 75 ++++++++-------- .../views/admin/airports/fields.blade.php | 46 +++++----- resources/views/admin/fares/fields.blade.php | 10 +-- .../views/admin/flights/fields.blade.php | 88 +++++++++---------- 12 files changed, 153 insertions(+), 136 deletions(-) diff --git a/app/Http/Controllers/Admin/FlightController.php b/app/Http/Controllers/Admin/FlightController.php index c5358cb2..6419af17 100644 --- a/app/Http/Controllers/Admin/FlightController.php +++ b/app/Http/Controllers/Admin/FlightController.php @@ -72,7 +72,7 @@ class FlightController extends BaseController return view('admin.flights.create', [ 'flight' => null, 'airlines' => $this->airlineRepo->selectBoxList(), - 'airports' => $this->airportRepo->selectBoxList(), + 'airports' => $this->airportRepo->selectBoxList(true, false), ]); } diff --git a/app/Http/Controllers/Admin/PirepFieldController.php b/app/Http/Controllers/Admin/PirepFieldController.php index 3866e8a3..0bc77aeb 100644 --- a/app/Http/Controllers/Admin/PirepFieldController.php +++ b/app/Http/Controllers/Admin/PirepFieldController.php @@ -31,7 +31,7 @@ class PirepFieldController extends BaseController $this->pirepFieldRepo->pushCriteria(new RequestCriteria($request)); $fields = $this->pirepFieldRepo->all(); - return view('admin.pirepFields.index', [ + return view('admin.pirepfields.index', [ 'fields' => $fields, ]); } @@ -43,7 +43,7 @@ class PirepFieldController extends BaseController */ public function create() { - return view('admin.pirepFields.create'); + return view('admin.pirepfields.create'); } /** @@ -60,7 +60,7 @@ class PirepFieldController extends BaseController $field = $this->pirepFieldRepo->create($input); Flash::success('PirepField saved successfully.'); - return redirect(route('admin.pirepFields.index')); + return redirect(route('admin.pirepfields.index')); } /** @@ -76,10 +76,10 @@ class PirepFieldController extends BaseController if (empty($field)) { Flash::error('PirepField not found'); - return redirect(route('admin.pirepFields.index')); + return redirect(route('admin.pirepfields.index')); } - return view('admin.pirepFields.show', [ + return view('admin.pirepfields.show', [ 'field' => $field, ]); } @@ -97,10 +97,10 @@ class PirepFieldController extends BaseController if (empty($field)) { Flash::error('PirepField not found'); - return redirect(route('admin.pirepFields.index')); + return redirect(route('admin.pirepfields.index')); } - return view('admin.pirepFields.edit', [ + return view('admin.pirepfields.edit', [ 'field' => $field, ]); } @@ -119,13 +119,13 @@ class PirepFieldController extends BaseController if (empty($field)) { Flash::error('PirepField not found'); - return redirect(route('admin.pirepFields.index')); + return redirect(route('admin.pirepfields.index')); } $field = $this->pirepFieldRepo->update($request->all(), $id); Flash::success('PirepField updated successfully.'); - return redirect(route('admin.pirepFields.index')); + return redirect(route('admin.pirepfields.index')); } /** @@ -141,12 +141,12 @@ class PirepFieldController extends BaseController if (empty($field)) { Flash::error('PirepField not found'); - return redirect(route('admin.pirepFields.index')); + return redirect(route('admin.pirepfields.index')); } $this->pirepFieldRepo->delete($id); Flash::success('PirepField deleted successfully.'); - return redirect(route('admin.pirepFields.index')); + return redirect(route('admin.pirepfields.index')); } } diff --git a/app/Models/Acars.php b/app/Models/Acars.php index 3a895335..4e270054 100644 --- a/app/Models/Acars.php +++ b/app/Models/Acars.php @@ -7,9 +7,9 @@ use App\Models\Traits\HashId; class Acars extends BaseModel { use HashId; - public $incrementing = false; public $table = 'acars'; + public $incrementing = false; public $fillable = [ 'pirep_id', @@ -37,6 +37,10 @@ class Acars extends BaseModel 'fuel_flow' => 'float', ]; + public static $rules = [ + 'pirep_id' => 'required', + ]; + /** * FKs */ diff --git a/app/Models/Aircraft.php b/app/Models/Aircraft.php index bf012945..cbd77ed0 100644 --- a/app/Models/Aircraft.php +++ b/app/Models/Aircraft.php @@ -6,8 +6,6 @@ class Aircraft extends BaseModel { public $table = 'aircraft'; - protected $dates = ['deleted_at']; - public $fillable = [ 'subfleet_id', 'airport_id', diff --git a/app/Models/Airline.php b/app/Models/Airline.php index 34f7afd0..403cf2d6 100644 --- a/app/Models/Airline.php +++ b/app/Models/Airline.php @@ -34,9 +34,11 @@ class Airline extends BaseModel * @var array */ public static $rules = [ - 'iata' => 'required|max:5', - 'icao' => 'required|max:5', - 'name' => 'required', + 'country' => 'nullable', + 'iata' => 'nullable|max:5', + 'icao' => 'required|max:5', + 'logo' => 'nullable', + 'name' => 'required', ]; /** @@ -46,4 +48,21 @@ class Airline extends BaseModel return $this->icao; } + protected static function boot() + { + parent::boot(); + + /** + * IATA and ICAO should be in all caps + */ + static::creating(function (Airline $model) { + if (!empty($model->iata)) { + $model->iata = strtoupper($model->iata); + } + + if (!empty($model->icao)) { + $model->icao = strtoupper($model->icao); + } + }); + } } diff --git a/app/Models/Airport.php b/app/Models/Airport.php index b4cad11e..6dbb145b 100644 --- a/app/Models/Airport.php +++ b/app/Models/Airport.php @@ -38,14 +38,12 @@ class Airport extends BaseModel /** * Validation rules - * - * @var array */ public static $rules = [ - 'icao' => 'required', - 'name' => 'required', - 'lat' => 'required', - 'lon' => 'required', + 'icao' => 'required', + 'name' => 'required', + 'lat' => 'required', + 'lon' => 'required', ]; /** diff --git a/app/Models/Setting.php b/app/Models/Setting.php index 8d772003..2687b55c 100644 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -35,5 +35,4 @@ class Setting extends BaseModel } }); } - } diff --git a/resources/views/admin/aircraft/fields.blade.php b/resources/views/admin/aircraft/fields.blade.php index 0fe2eed8..4215238e 100644 --- a/resources/views/admin/aircraft/fields.blade.php +++ b/resources/views/admin/aircraft/fields.blade.php @@ -1,7 +1,7 @@
- {!! Form::label('name', 'Name:') !!} * + {!! Form::label('name', 'Name:') !!} * {!! Form::text('name', null, ['class' => 'form-control']) !!}
diff --git a/resources/views/admin/airlines/fields.blade.php b/resources/views/admin/airlines/fields.blade.php index 87a075c1..97cfcf1e 100644 --- a/resources/views/admin/airlines/fields.blade.php +++ b/resources/views/admin/airlines/fields.blade.php @@ -1,40 +1,45 @@
- -
- {!! Form::label('icao', 'Code:') !!} - {!! Form::text('icao', null, ['class' => 'form-control']) !!} -
+ +
+ {!! Form::label('icao', 'Code:') !!} * + {!! Form::text('icao', null, ['class' => 'form-control']) !!} +
-
- {!! Form::label('iata', 'IATA:') !!} - {!! Form::text('iata', null, ['class' => 'form-control']) !!} -
- - -
- {!! Form::label('name', 'Name:') !!} - {!! Form::text('name', null, ['class' => 'form-control']) !!} -
- -
- {!! Form::label('logo', 'Logo URL:') !!} - {!! Form::text('logo', null, ['class' => 'form-control']) !!} -
- - -
- {!! Form::label('active', 'Active:') !!} - -
- - -
-
- {!! Form::submit('Save', ['class' => 'btn btn-primary']) !!} - Cancel + +
+ {!! Form::label('name', 'Name:') !!} * + {!! Form::text('name', null, ['class' => 'form-control']) !!}
+
+
+ {!! Form::label('iata', 'IATA:') !!} + {!! Form::text('iata', null, ['class' => 'form-control']) !!} +
+ +
+ {!! Form::label('logo', 'Logo URL:') !!} + {!! Form::text('logo', null, ['class' => 'form-control']) !!} +
+ +
+ +
+ +
+ {!! Form::label('active', 'Active:') !!} + +
+
+
+ +
+
+ {!! Form::submit('Save', ['class' => 'btn btn-primary']) !!} + Cancel +
+
diff --git a/resources/views/admin/airports/fields.blade.php b/resources/views/admin/airports/fields.blade.php index b46359cd..f07f59a0 100644 --- a/resources/views/admin/airports/fields.blade.php +++ b/resources/views/admin/airports/fields.blade.php @@ -3,36 +3,47 @@
- {!! Form::label('icao', 'ICAO:') !!} + {!! Form::label('icao', 'ICAO:') !!} * Lookup {!! Form::text('icao', null, [ - 'id' => 'airport_icao', 'class' => 'form-control', - 'rv-value' => 'airport.icao' + 'id' => 'airport_icao', 'class' => 'form-control' ]) !!}
- {!! Form::label('iata', 'IATA:') !!} - {!! Form::text('iata', null, ['class' => 'form-control', 'rv-value' => 'airport.iata']) !!} + {!! Form::label('name', 'Name:') !!} * + {!! Form::text('name', null, ['class' => 'form-control']) !!}
- {!! Form::label('name', 'Name:') !!} - {!! Form::text('name', null, ['class' => 'form-control', 'rv-value' => 'airport.name']) !!} + {!! Form::label('lat', 'Latitude:') !!} * + {!! Form::number('lat', null, ['class' => 'form-control', 'step' => '0.000001', 'rv-value' => 'airport.lat']) !!} +
+ +
+ {!! Form::label('lon', 'Longitude:') !!} * + {!! Form::number('lon', null, ['class' => 'form-control', 'step' => '0.000001', 'rv-value' => 'airport.lon']) !!} +
+
+ +
+
+ {!! Form::label('iata', 'IATA:') !!} + {!! Form::text('iata', null, ['class' => 'form-control']) !!}
{!! Form::label('location', 'Location:') !!} - {!! Form::text('location', null, ['class' => 'form-control', 'rv-value' => 'airport.city']) !!} + {!! Form::text('location', null, ['class' => 'form-control']) !!}
{!! Form::label('country', 'Country:') !!} - {!! Form::text('country', null, ['class' => 'form-control', 'rv-value' => 'airport.country']) !!} + {!! Form::text('country', null, ['class' => 'form-control']) !!}
@@ -42,27 +53,14 @@
-
- {!! Form::label('lat', 'Latitude:') !!} - {!! Form::number('lat', null, ['class' => 'form-control', 'step' => '0.000001', 'rv-value' => 'airport.lat']) !!} -
- -
- {!! Form::label('lon', 'Longitude:') !!} - {!! Form::number('lon', null, ['class' => 'form-control', 'step' => '0.000001', 'rv-value' => 'airport.lon']) !!} -
-
{!! Form::label('hub', 'Hub:') !!} {!! Form::hidden('hub', 0) !!} {!! Form::checkbox('hub', null) !!}
-
- -
-
-
+
+
{!! Form::submit('Save', ['class' => 'btn btn-primary']) !!} Cancel
diff --git a/resources/views/admin/fares/fields.blade.php b/resources/views/admin/fares/fields.blade.php index 9cb61ed8..11d43508 100644 --- a/resources/views/admin/fares/fields.blade.php +++ b/resources/views/admin/fares/fields.blade.php @@ -10,7 +10,7 @@
- {!! Form::label('code', 'Code:') !!} + {!! Form::label('code', 'Code:') !!} *
   How this fare class will show up on a ticket @@ -19,7 +19,7 @@
- {!! Form::label('name', 'Name:') !!} + {!! Form::label('name', 'Name:') !!} *
   The fare class name, E.g, "Economy" or "First" @@ -33,7 +33,7 @@    This is the price of a ticket for a passenger
- {!! Form::text('price', null, ['class' => 'form-control']) !!} + {!! Form::text('price', null, ['class' => 'form-control', 'placeholder' => 0]) !!}
@@ -42,7 +42,7 @@    The operating cost
- {!! Form::text('cost', null, ['class' => 'form-control']) !!} + {!! Form::text('cost', null, ['class' => 'form-control', 'placeholder' => 0]) !!}
@@ -51,7 +51,7 @@    The number of seats available in this class.
- {!! Form::text('capacity', null, ['class' => 'form-control']) !!} + {!! Form::text('capacity', null, ['class' => 'form-control', 'placeholder' => 0]) !!}
diff --git a/resources/views/admin/flights/fields.blade.php b/resources/views/admin/flights/fields.blade.php index 03e54796..8124bc79 100644 --- a/resources/views/admin/flights/fields.blade.php +++ b/resources/views/admin/flights/fields.blade.php @@ -1,36 +1,26 @@
-
- {!! Form::label('airline_id', 'Airline:') !!} +
+ {!! Form::label('airline_id', 'Airline:') !!} * {!! Form::select('airline_id', $airlines, null , ['class' => 'form-control select2']) !!} +

{{ $errors->first('airline_id') }}

-
- {!! Form::label('flight_number', 'Flight Number:') !!} +
+ {!! Form::label('flight_number', 'Flight Number:') !!} * {!! Form::text('flight_number', null, ['class' => 'form-control']) !!} +

{{ $errors->first('flight_number') }}

- -
- {!! Form::label('active', 'Active:') !!} - @if($flight!==null) - {!! Form::checkbox('active', $flight->active, ['class' => 'form-control icheck']) !!} - @else - {!! Form::checkbox('active', null, ['class' => 'form-control icheck']) !!} - @endif -
-
- -
-
+
{!! Form::label('route_code', 'Route Code:') !!} {!! Form::text('route_code', null, ['class' => 'form-control']) !!}
-
+
{!! Form::label('route_leg', 'Route Leg:') !!} {!! Form::text('route_leg', null, ['class' => 'form-control']) !!}
@@ -43,14 +33,16 @@ SAME ROW
- {!! Form::label('dpt_airport_id', 'Departure Airport:') !!} + {!! Form::label('dpt_airport_id', 'Departure Airport:') !!} * {!! Form::select('dpt_airport_id', $airports, null , ['class' => 'form-control select2']) !!} +

{{ $errors->first('dpt_airport_id') }}

- {!! Form::label('arr_airport_id', 'Arrival Airport:') !!} + {!! Form::label('arr_airport_id', 'Arrival Airport:') !!} * {!! Form::select('arr_airport_id', $airports, null , ['class' => 'form-control select2']) !!} +

{{ $errors->first('arr_airport_id') }}

@@ -60,45 +52,49 @@ SAME ROW
-
-
- {!! Form::label('dpt_time', 'Departure Time:') !!} - {!! Form::text('dpt_time', null, ['class' => 'form-control']) !!} -
+
+ {!! Form::label('dpt_time', 'Departure Time:') !!} + {!! Form::text('dpt_time', null, ['class' => 'form-control']) !!} +
- -
- {!! Form::label('arr_time', 'Arrival Time:') !!} - {!! Form::text('arr_time', null, ['class' => 'form-control']) !!} -
+ +
+ {!! Form::label('arr_time', 'Arrival Time:') !!} + {!! Form::text('arr_time', null, ['class' => 'form-control']) !!} +
- -
- {!! Form::label('route', 'Route:') !!} - {!! Form::text('route', null, ['class' => 'form-control']) !!} -
+ +
+ {!! Form::label('route', 'Route:') !!} + {!! Form::textarea('route', null, ['class' => 'form-control']) !!} +
- -
- {!! Form::label('notes', 'Notes:') !!} - {!! Form::text('notes', null, ['class' => 'form-control']) !!} -
+ +
+ {!! Form::label('notes', 'Notes:') !!} + {!! Form::textarea('notes', null, ['class' => 'form-control']) !!} +
-
-
-
+ +
+ {!! Form::label('active', 'Active:') !!} + @if($flight!==null) + {!! Form::checkbox('active', $flight->active, ['class' => 'form-control icheck']) !!} + @else + {!! Form::checkbox('active', null, ['class' => 'form-control icheck']) !!} + @endif +
+
+
{!! Form::submit('Save', ['class' => 'btn btn-primary']) !!} Cancel
-