From 9b6f9e9586d1d8dc7e16d8e2891cd37f02dc65bb Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Sun, 2 Jul 2017 21:25:48 -0500 Subject: [PATCH] #21 basic listings/model configs --- app/Models/Pirep.php | 4 +++ app/Models/User.php | 5 +++ config/app.php | 1 + config/infyom/laravel_generator.php | 4 +-- database/seeds/dev.yml | 27 ++++++++++++----- resources/views/admin/pireps/table.blade.php | 32 +++++++++++++------- 6 files changed, 52 insertions(+), 21 deletions(-) diff --git a/app/Models/Pirep.php b/app/Models/Pirep.php index e54806dc..d5a35aea 100644 --- a/app/Models/Pirep.php +++ b/app/Models/Pirep.php @@ -67,6 +67,10 @@ class Pirep extends Model /** * Foreign Keys */ + public function aircraft() + { + return $this->belongsTo('App\Models\Aircraft', 'aircraft_id'); + } public function arr_airport() { diff --git a/app/Models/User.php b/app/Models/User.php index 246f4bd6..2c2ca687 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -52,6 +52,11 @@ class User extends Authenticatable 'password', 'remember_token', ]; + public function pilot_id() + { + return $this->airline->code . str_pad($this->id, 3, '0', STR_PAD_LEFT); + } + /** * Foreign Keys */ diff --git a/config/app.php b/config/app.php index 4410c59f..71e57255 100755 --- a/config/app.php +++ b/config/app.php @@ -111,6 +111,7 @@ return [ 'Yaml' => Symfony\Component\Yaml\Yaml::class, 'Geotools' => Toin0u\Geotools\Facade\Geotools::class, 'Setting' => anlutro\LaravelSettings\Facade::class, + 'Utils' => App\Facades\Utils::class, ], ]; diff --git a/config/infyom/laravel_generator.php b/config/infyom/laravel_generator.php index 99d7ac25..0b5abe72 100644 --- a/config/infyom/laravel_generator.php +++ b/config/infyom/laravel_generator.php @@ -40,7 +40,7 @@ return [ 'api_version' => 'v1', 'options' => [ - 'softDelete' => true, + 'softDelete' => false, 'tables_searchable_default' => false, ], @@ -54,7 +54,7 @@ return [ 'add_on' => [ - 'swagger' => false, + 'swagger' => true, 'tests' => true, 'datatables' => false, 'menu' => [ diff --git a/database/seeds/dev.yml b/database/seeds/dev.yml index 7cce025b..6f94a6f1 100644 --- a/database/seeds/dev.yml +++ b/database/seeds/dev.yml @@ -108,14 +108,6 @@ fares: price: 800 capacity: 5 -flights: - - id: 1 - airline_id: 1 - flight_number: 100 - dpt_airport_id: 1 - arr_airport_id: 2 - route: KAUS KJFK - subfleets: - id: 1 airline_id: 1 @@ -152,3 +144,22 @@ subfleet_fare: subfleet_flight: - subfleet_id: 1 flight_id: 1 + +flights: + - id: 1 + airline_id: 1 + flight_number: 100 + dpt_airport_id: 1 + arr_airport_id: 2 + route: KAUS KJFK + +pireps: + - user_id: 1 + flight_id: 1 + aircraft_id: 1 + dpt_airport_id: 1 + arr_airport_id: 2 + flight_time: 21600 # 6 hours + level: 320 + status: -1 + notes: just a pilot report diff --git a/resources/views/admin/pireps/table.blade.php b/resources/views/admin/pireps/table.blade.php index 3f300c3f..a5d4de3b 100644 --- a/resources/views/admin/pireps/table.blade.php +++ b/resources/views/admin/pireps/table.blade.php @@ -1,26 +1,30 @@ - - - + + + - - @foreach($pireps as $pirep) - - - - + + + + - - + @if($pirep->notes) + + + + + @endif @endforeach
User IdFlight IdAircraft IdPilotFlightAircraft Flight Time Level RouteNotesRaw Data Action
{!! $pirep->user_id !!}{!! $pirep->flight_id !!}{!! $pirep->aircraft_id !!}{!! $pirep->flight_time !!}{!! $pirep->user->name !!} + @if($pirep->flight) + + {!! $pirep->flight->airline->code !!}{!! $pirep->flight->flight_number !!} + + @else + - + @endif + {!! $pirep->aircraft->registration !!} ({!! $pirep->aircraft->name !!}){!! Utils::secondsToTime($pirep->flight_time) !!} {!! $pirep->level !!} {!! $pirep->route !!}{!! $pirep->notes !!}{!! $pirep->raw_data !!} {!! Form::open(['route' => ['admin.pireps.destroy', $pirep->id], 'method' => 'delete']) !!}
@@ -31,6 +35,12 @@ {!! Form::close() !!}
 Notes: {!! $pirep->notes !!}