Add the validation error fields in the templates

This commit is contained in:
Nabeel Shahzad 2018-02-06 10:18:22 -06:00
parent 995d53df3e
commit 8d76e16220
12 changed files with 77 additions and 10 deletions

View File

@ -2,12 +2,18 @@
namespace App\Models;
use App\Models\Observers\AirportObserver;
use Illuminate\Notifications\Notifiable;
use Log;
/**
* Class Airport
* @package App\Models
*/
class Airport extends BaseModel
{
use Notifiable;
public $table = 'airports';
public $timestamps = false;
public $incrementing = false;
@ -50,11 +56,21 @@ class Airport extends BaseModel
/**
* Callbacks
*/
protected static function boot()
public static function boot()
{
parent::boot();
static::creating(function (Airport $model) {
if(!empty($model->iata)) {
static::creating(function ($model) {
if(filled($model->iata)) {
$model->iata = strtoupper(trim($model->iata));
}
$model->icao = strtoupper(trim($model->icao));
$model->id = $model->icao;
});
static::updating(function($model) {
if (filled($model->iata)) {
$model->iata = strtoupper(trim($model->iata));
}

View File

@ -3,11 +3,13 @@
<div class="form-group col-sm-6">
{!! Form::label('name', 'Name:') !!}&nbsp;<span class="required">*</span>
{!! Form::text('name', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('name') }}</p>
</div>
<div class="form-group col-sm-6">
{!! Form::label('subfleet_id', 'Subfleet:') !!}
{!! Form::select('subfleet_id', $subfleets, null, ['class' => 'form-control select2', 'placeholder' => 'Select Subfleet']) !!}
<p class="text-danger">{{ $errors->first('subfleet_id') }}</p>
</div>
</div>
@ -15,23 +17,27 @@
<div class="form-group col-sm-3">
{!! Form::label('icao', 'ICAO:') !!}
{!! Form::text('icao', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('icao') }}</p>
</div>
<!-- Registration Field -->
<div class="form-group col-sm-3">
{!! Form::label('registration', 'Registration:') !!}
{!! Form::text('registration', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('registration') }}</p>
</div>
<!-- Tail Number Field -->
<div class="form-group col-sm-3">
{!! Form::label('tail_number', 'Tail Number:') !!}
{!! Form::text('tail_number', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('tail_number') }}</p>
</div>
<div class="form-group col-sm-3">
{!! Form::label('zfw', 'Zero Fuel Weight:') !!}
{!! Form::text('zfw', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('zfw') }}</p>
</div>
</div>
<div class="row">

View File

@ -3,23 +3,27 @@
<div class="form-group col-sm-6">
{!! Form::label('icao', 'Code:') !!}&nbsp;<span class="required">*</span>
{!! Form::text('icao', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('icao') }}</p>
</div>
<!-- Name Field -->
<div class="form-group col-sm-6">
{!! Form::label('name', 'Name:') !!}&nbsp;<span class="required">*</span>
{!! Form::text('name', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('name') }}</p>
</div>
</div>
<div class="row">
<div class="form-group col-sm-6">
{!! Form::label('iata', 'IATA:') !!}
{!! Form::text('iata', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('iata') }}</p>
</div>
<div class="form-group col-sm-6">
{!! Form::label('logo', 'Logo URL:') !!}
{!! Form::text('logo', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('logo') }}</p>
</div>
</div>

View File

@ -8,11 +8,13 @@
{!! Form::text('icao', null, [
'id' => 'airport_icao', 'class' => 'form-control'
]) !!}
<p class="text-danger">{{ $errors->first('icao') }}</p>
</div>
<div class="form-group col-sm-6">
{!! Form::label('name', 'Name:') !!}&nbsp;<span class="required">*</span>
{!! Form::text('name', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('name') }}</p>
</div>
</div>
@ -20,11 +22,13 @@
<div class="form-group col-sm-6">
{!! Form::label('lat', 'Latitude:') !!}&nbsp;<span class="required">*</span>
{!! Form::number('lat', null, ['class' => 'form-control', 'step' => '0.000001', 'rv-value' => 'airport.lat']) !!}
<p class="text-danger">{{ $errors->first('lat') }}</p>
</div>
<div class="form-group col-sm-6">
{!! Form::label('lon', 'Longitude:') !!}&nbsp;<span class="required">*</span>
{!! Form::number('lon', null, ['class' => 'form-control', 'step' => '0.000001', 'rv-value' => 'airport.lon']) !!}
<p class="text-danger">{{ $errors->first('lon') }}</p>
</div>
</div>
@ -32,11 +36,13 @@
<div class="form-group col-sm-6">
{!! Form::label('iata', 'IATA:') !!}
{!! Form::text('iata', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('iata') }}</p>
</div>
<div class="form-group col-sm-6">
{!! Form::label('location', 'Location:') !!}
{!! Form::text('location', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('location') }}</p>
</div>
</div>
@ -44,11 +50,13 @@
<div class="form-group col-sm-6">
{!! Form::label('country', 'Country:') !!}
{!! Form::text('country', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('country') }}</p>
</div>
<div class="form-group col-sm-6">
{!! Form::label('tz', 'Timezone:') !!}
{!! Form::select('tz', $timezones, null, ['class' => 'select2']); !!}
<p class="text-danger">{{ $errors->first('tz') }}</p>
</div>
</div>

View File

@ -16,6 +16,7 @@
How this fare class will show up on a ticket
</div>
{!! Form::text('code', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('code') }}</p>
</div>
<div class="form-group col-sm-6">
@ -25,6 +26,7 @@
The fare class name, E.g, "Economy" or "First"
</div>
{!! Form::text('name', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('name') }}</p>
</div>
<div class="form-group col-sm-6">
@ -34,6 +36,7 @@
This is the price of a ticket for a passenger
</div>
{!! Form::text('price', null, ['class' => 'form-control', 'placeholder' => 0]) !!}
<p class="text-danger">{{ $errors->first('price') }}</p>
</div>
<div class="form-group col-sm-6">
@ -43,6 +46,7 @@
The operating cost
</div>
{!! Form::text('cost', null, ['class' => 'form-control', 'placeholder' => 0]) !!}
<p class="text-danger">{{ $errors->first('cost') }}</p>
</div>
<div class="form-group col-sm-6">
@ -52,6 +56,7 @@
The number of seats available in this class.
</div>
{!! Form::text('capacity', null, ['class' => 'form-control', 'placeholder' => 0]) !!}
<p class="text-danger">{{ $errors->first('capacity') }}</p>
</div>
<div class="form-group col-sm-6">
@ -60,6 +65,7 @@
&nbsp;
</div>
{!! Form::text('notes', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('notes') }}</p>
</div>
<!-- Active Field -->

View File

@ -57,6 +57,7 @@ SAME ROW
<div class="form-group col-sm-3">
{!! Form::label('alt_airport_id', 'Alt Airport:') !!}
{!! Form::select('alt_airport_id', $airports, null , ['class' => 'form-control select2']) !!}
<p class="text-danger">{{ $errors->first('alt_airport_id') }}</p>
</div>
</div>
@ -66,11 +67,13 @@ SAME ROW
<div class="form-group col-sm-3">
{!! Form::label('dpt_time', 'Departure Time:') !!}
{!! Form::text('dpt_time', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('dpt_time') }}</p>
</div>
<div class="form-group col-sm-3">
{!! Form::label('arr_time', 'Arrival Time:') !!}
{!! Form::text('arr_time', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('arr_time') }}</p>
</div>
<div class="form-group col-sm-2">
@ -97,12 +100,14 @@ SAME ROW
<div class="form-group col-sm-6">
{!! Form::label('route', 'Route:') !!}
{!! Form::textarea('route', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('route') }}</p>
</div>
<!-- Notes Field -->
<div class="form-group col-sm-6">
{!! Form::label('notes', 'Notes:') !!}
{!! Form::textarea('notes', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('notes') }}</p>
</div>
</div>

View File

@ -51,6 +51,8 @@
{!! Form::button('<i class="glyphicon glyphicon-plus"></i> add',
['type' => 'submit',
'class' => 'btn btn-success btn-s']) !!}
<p class="text-danger">{{ $errors->first('name') }}</p>
<p class="text-danger">{{ $errors->first('tz') }}</p>
{!! Form::close() !!}
</div>
</div>

View File

@ -2,6 +2,7 @@
<div class="form-group col-sm-6">
{!! Form::label('name', 'Name:') !!}&nbsp;&nbsp;<span class="required">*</span>
{!! Form::text('name', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('name') }}</p>
</div>
<!-- Required Field -->

View File

@ -14,12 +14,15 @@
<div class="row">
<div class="col-sm-4">
{!! Form::text('flight_number', null, ['placeholder' => 'Flight Number', 'class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('flight_number') }}</p>
</div>
<div class="col-sm-4">
{!! Form::text('route_code', null, ['placeholder' => 'Code (optional)', 'class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('route_code') }}</p>
</div>
<div class="col-sm-4">
{!! Form::text('route_leg', null, ['placeholder' => 'Leg (optional)', 'class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('route_leg') }}</p>
</div>
</div>
</div>
@ -28,6 +31,7 @@
<div class="row">
<div class="col-sm-12">
{!! Form::select('airline_id', $airlines, null, ['class' => 'form-control select2']) !!}
<p class="text-danger">{{ $errors->first('airline_id') }}</p>
</div>
</div>
</div>
@ -36,15 +40,18 @@
<div class="form-group col-sm-4">
{!! Form::label('aircraft_id', 'Aircraft:') !!}
{!! Form::select('aircraft_id', $aircraft, null, ['class' => 'form-control select2']) !!}
<p class="text-danger">{{ $errors->first('aircraft_id') }}</p>
</div>
<div class="form-group col-sm-4">
{!! Form::label('dpt_airport_id', 'Departure Airport:') !!}
{!! Form::select('dpt_airport_id', $airports, null, ['class' => 'form-control select2']) !!}
<p class="text-danger">{{ $errors->first('dpt_airport_id') }}</p>
</div>
<div class="form-group col-sm-4">
{!! Form::label('arr_airport_id', 'Arrival Airport:') !!}
{!! Form::select('arr_airport_id', $airports, null, ['class' => 'form-control select2']) !!}
<p class="text-danger">{{ $errors->first('arr_airport_id') }}</p>
</div>
</div>
<div class="row">
@ -58,6 +65,8 @@
<div class="col-sm-6">
{!! Form::number('minutes', null, ['class' => 'form-control', 'placeholder' => 'minutes']) !!}
</div>
<p class="text-danger">{{ $errors->first('hours') }}</p>
<p class="text-danger">{{ $errors->first('minutes') }}</p>
</div>
</div>
@ -67,6 +76,7 @@
<div class="row">
<div class="col-sm-12">
{!! Form::text('level', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('level') }}</p>
</div>
</div>
</div>
@ -76,22 +86,17 @@
<div class="form-group col-sm-6">
{!! Form::label('route', 'Route:') !!}
{!! Form::textarea('route', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('route') }}</p>
</div>
<!-- Notes Field -->
<div class="form-group col-sm-6">
{!! Form::label('notes', 'Notes:') !!}
{!! Form::textarea('notes', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('notes') }}</p>
</div>
</div>
<div class="row">
{{-- <!-- Raw Data Field -->
<div class="form-group col-sm-6">
{!! Form::label('raw_data', 'Raw Data:') !!}
{!! Form::textarea('raw_data', null, ['class' => 'form-control', 'disabled']) !!}
</div>--}}
<!-- Submit Field -->
<div class="form-group col-sm-12">
<div class="pull-right">
{!! Form::button('Save', ['type' => 'submit', 'class' => 'btn btn-success']) !!}

View File

@ -3,18 +3,21 @@
<div class="form-group col-sm-6">
{!! Form::label('name', 'Name:') !!}
{!! Form::text('name', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('name') }}</p>
</div>
<!-- Hours Field -->
<div class="form-group col-sm-6">
{!! Form::label('hours', 'Hours:') !!}
{!! Form::number('hours', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('hours') }}</p>
</div>
</div>
<div class="row">
<div class="form-group col-md-12">
{!! Form::label('image_link', 'Image Link:') !!}
{!! Form::number('image_link', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('image_link') }}</p>
</div>
</div>
<div class="row">

View File

@ -2,21 +2,25 @@
<div class="form-group col-sm-6">
{!! Form::label('airline_id', 'Airline:') !!}
{!! Form::select('airline_id', $airlines, null , ['class' => 'form-control select2']) !!}
<p class="text-danger">{{ $errors->first('airline_id') }}</p>
</div>
<div class="form-group col-sm-6">
{!! Form::label('name', 'Name:') !!}
{!! Form::text('name', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('name') }}</p>
</div>
<div class="form-group col-sm-6">
{!! Form::label('type', 'Type:') !!}
{!! Form::text('type', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('type') }}</p>
</div>
<div class="form-group col-sm-6">
{!! Form::label('fuel_type', 'Fuel Type:') !!}
{!! Form::select('fuel_type', $fuel_types, null , ['class' => 'form-control select2']) !!}
<p class="text-danger">{{ $errors->first('fuel_type') }}</p>
</div>
<div class="form-group col-sm-12">

View File

@ -2,16 +2,19 @@
<div class="form-group col-sm-4">
{!! Form::label('name', 'Name:') !!}
{!! Form::text('name', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('name') }}</p>
</div>
<div class="form-group col-sm-4">
{!! Form::label('email', 'Email:') !!}
{!! Form::text('email', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('email') }}</p>
</div>
<div class="form-group col-sm-4">
{!! Form::label('password', 'Password:') !!}
{!! Form::password('password', ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('password') }}</p>
</div>
</div>
@ -20,18 +23,22 @@
<div class="form-group">
{!! Form::label('country', 'Country:') !!} <br />
{!! Form::select('country', $countries, null, ['class' => 'select2' ]); !!}
<p class="text-danger">{{ $errors->first('country') }}</p>
</div>
<div class="form-group">
{!! Form::label('timezone', 'Timezone:') !!} <br/>
{!! Form::select('timezone', $timezones, null, ['id' => 'timezone', 'class' => 'select2' ]); !!}
<p class="text-danger">{{ $errors->first('timezone') }}</p>
</div>
</div>
<div class="form-group col-sm-6">
{!! Form::label('home_airport_id', 'Home Airport:') !!}
{!! Form::select('home_airport_id', $airports, null , ['class' => 'form-control select2']) !!}
<p class="text-danger">{{ $errors->first('home_airport_id') }}</p>
<br /><br />
{!! Form::label('curr_airport_id', 'Current Airport:') !!}
{!! Form::select('curr_airport_id', $airports, null , ['class' => 'form-control select2']) !!}
<p class="text-danger">{{ $errors->first('curr_airport_id') }}</p>
</div>
</div>