From beba08f6518a62deba52e6912a1f5d1239fbd8e9 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Wed, 16 Aug 2017 08:11:39 -0500 Subject: [PATCH] add/set ICAO and logo for airlines --- app/Models/Airline.php | 13 ++++++++++--- app/Models/User.php | 2 +- .../2017_06_08_191703_create_airlines_table.php | 3 ++- resources/views/admin/airlines/fields.blade.php | 9 +++++++-- .../views/admin/airlines/show_fields.blade.php | 15 +++++++-------- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/app/Models/Airline.php b/app/Models/Airline.php index 8dc8a3e7..a9800022 100644 --- a/app/Models/Airline.php +++ b/app/Models/Airline.php @@ -15,9 +15,11 @@ class Airline extends Model protected $dates = ['deleted_at']; public $fillable = [ - 'code', + 'icao', 'iata', 'name', + 'logo', + 'country', 'fuel_100ll_cost', 'fuel_jeta_cost', 'fuel_mogas_cost', @@ -30,8 +32,6 @@ class Airline extends Model * @var array */ protected $casts = [ - 'code' => 'string', - 'name' => 'string', 'fuel_100ll_cost' => 'double', 'fuel_jeta_cost' => 'double', 'fuel_mogas_cost' => 'double', @@ -48,4 +48,11 @@ class Airline extends Model 'name' => 'required', ]; + /** + * For backwards compatibility + */ + public function getCodeAttribute() { + return $this->icao; + } + } diff --git a/app/Models/User.php b/app/Models/User.php index c322a448..8299210f 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -87,7 +87,7 @@ class User extends Authenticatable public function pilot_id() { - return $this->airline->code.str_pad($this->id, 3, '0', STR_PAD_LEFT); + return $this->airline->icao.str_pad($this->id, 3, '0', STR_PAD_LEFT); } public function gravatar() diff --git a/database/migrations/2017_06_08_191703_create_airlines_table.php b/database/migrations/2017_06_08_191703_create_airlines_table.php index 79d840bc..edeaf2cb 100644 --- a/database/migrations/2017_06_08_191703_create_airlines_table.php +++ b/database/migrations/2017_06_08_191703_create_airlines_table.php @@ -15,10 +15,11 @@ class CreateAirlinesTable extends Migration { Schema::create('airlines', function (Blueprint $table) { $table->increments('id'); - $table->string('code', 5); + $table->string('icao', 5); $table->string('iata', 3)->nullable(); $table->string('name', 50); $table->string('country', 2)->nullable(); + $table->string('logo', 255)->nullable(); $table->boolean('active'); $table->timestamps(); diff --git a/resources/views/admin/airlines/fields.blade.php b/resources/views/admin/airlines/fields.blade.php index 43f8ff7b..96507521 100644 --- a/resources/views/admin/airlines/fields.blade.php +++ b/resources/views/admin/airlines/fields.blade.php @@ -1,7 +1,7 @@
- {!! Form::label('code', 'Code:') !!} - {!! Form::text('code', null, ['class' => 'form-control']) !!} + {!! Form::label('icao', 'Code:') !!} + {!! Form::text('icao', null, ['class' => 'form-control']) !!}
@@ -15,6 +15,11 @@ {!! Form::text('name', null, ['class' => 'form-control']) !!}
+
+ {!! Form::label('logo', 'Logo URL:') !!} + {!! Form::text('logo', null, ['class' => 'form-control']) !!} +
+
{!! Form::label('active', 'Active:') !!} diff --git a/resources/views/admin/airlines/show_fields.blade.php b/resources/views/admin/airlines/show_fields.blade.php index d9b88137..0add7264 100644 --- a/resources/views/admin/airlines/show_fields.blade.php +++ b/resources/views/admin/airlines/show_fields.blade.php @@ -1,13 +1,7 @@ - -
- {!! Form::label('id', 'Id:') !!} -

{!! $airlines->id !!}

-
-
- {!! Form::label('code', 'Code:') !!} -

{!! $airlines->code !!}

+ {!! Form::label('icao', 'ICAO:') !!} +

{!! $airlines->icao !!}

@@ -21,6 +15,11 @@

{!! $airlines->name !!}

+
+ {!! Form::label('logo', 'Logo URL:') !!} +

{!! $airlines->logo !!}

+
+
{!! Form::label('active', 'Active:') !!}