Skip to content

Commit

Permalink
Merge branch 'dev' into TrashBin
Browse files Browse the repository at this point in the history
  • Loading branch information
FatihKoz authored Sep 27, 2023
2 parents 53e9d23 + 7261bc5 commit ca4a42b
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
public function up()
{
if (!Schema::hasColumns('airports', ['elevation', 'region'])) {
Schema::table('airports', function (Blueprint $table) {
$table->integer('elevation')->nullable()->after('lon');
$table->string('region', 150)->nullable()->after('location');
});
}
}
};
4 changes: 1 addition & 3 deletions app/Http/Controllers/Admin/AirportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ public function index(Request $request): View
}

$this->airportRepo->pushCriteria(new WhereCriteria($request, $where));
$airports = $this->airportRepo
->orderBy('icao', 'asc')
->paginate();
$airports = $this->airportRepo->sortable('icao')->paginate();

return view('admin.airports.index', [
'airports' => $airports,
Expand Down
17 changes: 14 additions & 3 deletions app/Models/Airport.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* @property string full_name
* @property string description
* @property string location
* @property string region
* @property string country
* @property string timezone
* @property string notes
Expand All @@ -30,6 +31,7 @@
* @property float fuel_mogas_cost
* @property float lat
* @property float lon
* @property int elevation
*/
class Airport extends Model
{
Expand All @@ -53,9 +55,11 @@ class Airport extends Model
'icao',
'name',
'location',
'region',
'country',
'lat',
'lon',
'elevation',
'hub',
'timezone',
'tz',
Expand Down Expand Up @@ -84,8 +88,11 @@ class Airport extends Model
'iata' => 'sometimes|nullable',
'name' => 'required',
'location' => 'sometimes',
'region' => 'sometimes',
'country' => 'sometimes',
'lat' => 'required|numeric',
'lon' => 'required|numeric',
'elevation' => 'nullable|numeric',
'ground_handling_cost' => 'nullable|numeric',
'fuel_100ll_cost' => 'nullable|numeric',
'fuel_jeta_cost' => 'nullable|numeric',
Expand All @@ -97,7 +104,11 @@ class Airport extends Model
'iata',
'icao',
'name',
'hub',
'notes',
'elevation',
'location',
'region',
'country',
];

Expand Down Expand Up @@ -126,7 +137,7 @@ public function iata(): Attribute

/**
* Return full name like:
* KJFK/JFK - John F Kennedy
* KJFK - John F Kennedy
*
* @return string
*/
Expand All @@ -138,8 +149,8 @@ public function fullName(): Attribute
}

/**
* Return full name like:
* KJFK/JFK - John F Kennedy
* Return full description like:
* KJFK/JFK - John F Kennedy (hub)
*
* @return Attribute
*/
Expand Down
2 changes: 2 additions & 0 deletions app/Services/ImportExport/AirportImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ class AirportImporter extends ImportExport
'iata' => 'nullable',
'name' => 'required',
'location' => 'nullable',
'region' => 'nullable',
'country' => 'nullable',
'timezone' => 'nullable',
'hub' => 'nullable|boolean',
'lat' => 'required|numeric',
'lon' => 'required|numeric',
'elevation' => 'nullable|numeric',
'ground_handling_cost' => 'nullable|numeric',
'fuel_100ll_cost' => 'nullable|numeric',
'fuel_jeta_cost' => 'nullable|numeric',
Expand Down
32 changes: 16 additions & 16 deletions resources/views/admin/airports/fields.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
]) }}
<p class="text-danger">{{ $errors->first('icao') }}</p>
</div>

<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>

<div class="row">
Expand All @@ -25,35 +23,41 @@
{{ Form::text('name', null, ['class' => 'form-control']) }}
<p class="text-danger">{{ $errors->first('name') }}</p>
</div>
<div class="form-group col-sm-4">
<div class="form-group col-sm-3">
{{ Form::label('lat', 'Latitude:') }}&nbsp;<span class="required">*</span>
{{ Form::text('lat', null, ['class' => 'form-control', 'rv-value' => 'airport.lat']) }}
<p class="text-danger">{{ $errors->first('lat') }}</p>
</div>

<div class="form-group col-sm-4">
<div class="form-group col-sm-3">
{{ Form::label('lon', 'Longitude:') }}&nbsp;<span class="required">*</span>
{{ Form::text('lon', null, ['class' => 'form-control', 'rv-value' => 'airport.lon']) }}
<p class="text-danger">{{ $errors->first('lon') }}</p>
</div>
<div class="form-group col-sm-2">
{{ Form::label('elevation', 'Elevation:') }}
{{ Form::text('elevation', null, ['class' => 'form-control', 'rv-value' => 'airport.elevation']) }}
<p class="text-danger">{{ $errors->first('elevation') }}</p>
</div>
</div>

<div class="row">

<div class="form-group col-sm-4">
<div class="form-group col-sm-3">
{{ 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-4">
<div class="form-group col-sm-3">
{{ Form::label('location', 'Location:') }}
{{ Form::text('location', null, ['class' => 'form-control']) }}
<p class="text-danger">{{ $errors->first('location') }}</p>
</div>

<div class="form-group col-sm-4">
{{ Form::label('timezone', 'Timezone:') }}
<div class="form-group col-sm-3">
{{ Form::label('region', 'Region:') }}
{{ Form::text('region', null, ['class' => 'form-control']) }}
<p class="text-danger">{{ $errors->first('region') }}</p>
</div>
<div class="form-group col-sm-3">
{{ Form::label('timezone', 'Timezone:') }}<br>
{{ Form::select('timezone', $timezones, null, ['id' => 'timezone', 'class' => 'select2']) }}
<p class="text-danger">{{ $errors->first('timezone') }}</p>
</div>
Expand All @@ -64,7 +68,6 @@
{{ Form::label('ground_handling_cost', 'Ground Handling Cost:') }}
{{ Form::number('ground_handling_cost', null, ['class' => 'form-control', 'step' => '0.01']) }}
<p class="text-danger">{{ $errors->first('ground_handling_cost') }}</p>

@component('admin.components.info')
This is the base rate per-flight. A multiplier for this rate can be
set in the subfleet, so you can modulate those costs from there.
Expand All @@ -75,7 +78,6 @@
{{ Form::label('fuel_jeta_cost', 'Jet A Fuel Cost:') }}
{{ Form::number('fuel_jeta_cost', null, ['class' => 'form-control', 'step' => '0.01']) }}
<p class="text-danger">{{ $errors->first('fuel_jeta_cost') }}</p>

@component('admin.components.info')
This is the cost per {{ config('phpvms.internal_units.fuel') }}
@endcomponent
Expand All @@ -85,7 +87,6 @@
{{ Form::label('fuel_100ll_cost', '100LL Fuel Cost:') }}
{{ Form::number('fuel_100ll_cost', null, ['class' => 'form-control', 'step' => '0.01']) }}
<p class="text-danger">{{ $errors->first('fuel_100ll_cost') }}</p>

@component('admin.components.info')
This is the cost per {{ config('phpvms.internal_units.fuel') }}
@endcomponent
Expand All @@ -95,7 +96,6 @@
{{ Form::label('fuel_mogas_cost', 'MOGAS Fuel Cost:') }}
{{ Form::number('fuel_mogas_cost', null, ['class' => 'form-control', 'step' => '0.01']) }}
<p class="text-danger">{{ $errors->first('fuel_mogas_cost') }}</p>

@component('admin.components.info')
This is the cost per {{ config('phpvms.internal_units.fuel') }}
@endcomponent
Expand Down
18 changes: 12 additions & 6 deletions resources/views/admin/airports/table.blade.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<div id="airports_table_wrapper">
<table class="table table-hover table-responsive" id="airports-table">
<thead>
<th>ICAO</th>
<th>IATA</th>
<th>Name</th>
<th>Location</th>
<th style="text-align: center;">Hub</th>
<th style="text-align: center;">Notes</th>
<th>@sortablelink('icao', 'ICAO')</th>
<th>@sortablelink('iata', 'IATA')</th>
<th>@sortablelink('name', 'Name')</th>
<th>@sortablelink('location', 'Location')</th>
<th>@sortablelink('region', 'Region')</th>
<th>@sortablelink('country', 'Country')</th>
<th>@sortablelink('elevation', 'Elevation')</th>
<th style="text-align: center;">@sortablelink('hub', 'Hub')</th>
<th style="text-align: center;">@sortablelink('notes', 'Notes')</th>
<th style="text-align: center;">GH Cost</th>
<th style="text-align: center;">JetA</th>
<th style="text-align: center;">100LL</th>
Expand All @@ -20,6 +23,9 @@
<td><a href="{{ route('admin.airports.edit', [$airport->id]) }}">{{ $airport->iata }}</a></td>
<td>{{ $airport->name }}</td>
<td>{{ $airport->location }}</td>
<td>{{ $airport->region }}</td>
<td>{{ $airport->country }}</td>
<td>{{ $airport->elevation }}</td>
<td style="text-align: center;">
@if($airport->hub === true)
<span class="label label-success">Hub</span>
Expand Down
11 changes: 7 additions & 4 deletions resources/views/layouts/default/airports/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
@section('content')
<div class="row" style="margin-bottom: 30px;">
<div class="col-12">
<h2>{{ $airport->full_name }}</h2>
<h2>
{{ $airport->full_name }}
@if(filled($airport->elevation))
<span class="float-right">{{'| '.$airport->elevation.'ft'}}</span>
@endif
</h2>
</div>

{{-- Show the weather widget in one column --}}
<div class="col-5">
{{ Widget::Weather([
'icao' => $airport->icao,
]) }}
{{ Widget::Weather(['icao' => $airport->icao]) }}
</div>

{{-- Show the airspace map in the other column --}}
Expand Down
5 changes: 3 additions & 2 deletions tests/ImporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,9 @@ public function testAirportImporter(): void
$this->assertEquals('AUS', $airport->iata);
$this->assertEquals('KAUS', $airport->icao);
$this->assertEquals('Austin-Bergstrom', $airport->name);
$this->assertEquals('Austin, Texas, USA', $airport->location);
$this->assertEquals('United States', $airport->country);
$this->assertEquals('Austin', $airport->location);
$this->assertEquals('Texas', $airport->region);
$this->assertEquals('US', $airport->country);
$this->assertEquals('America/Chicago', $airport->timezone);
$this->assertEquals(true, $airport->hub);
$this->assertEquals('30.1945', $airport->lat);
Expand Down
8 changes: 4 additions & 4 deletions tests/data/airports.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
icao,iata,name,location,country,timezone,hub,lat,lon,ground_handling_cost,fuel_100ll_cost,fuel_jeta_cost,fuel_mogas_cost,notes
KAUS,AUS,Austin-Bergstrom,"Austin, Texas, USA", United States,America/Chicago,1,30.1945,-97.6699,0,,,,"Test Note"
KSFO,SFO,San Francisco,"San Francisco, California, USA", United States,America/California,1,30.1945,-97.6699,,,0.9,,
KJFK,JFK,Kennedy,"Queens, New York, USA", United States,America/New_York,0,30.1945,abcd,150,,0.8,,"Busy Airport"
icao,iata,name,location,region,country,timezone,hub,lat,lon,elevation,ground_handling_cost,fuel_100ll_cost,fuel_jeta_cost,fuel_mogas_cost,notes
KAUS,AUS,Austin-Bergstrom,"Austin","Texas",US,America/Chicago,1,30.1945,-97.6699,148,0,,,,"Test Note"
KSFO,SFO,San Francisco,"San Francisco","California",US,America/California,1,30.1945,-97.6699,,,,0.9,,
KJFK,JFK,Kennedy,"Queens","New York",US,America/New_York,0,30.1945,abcd,58,150,,0.8,,"Busy Airport"
20 changes: 10 additions & 10 deletions tests/data/airports_special_chars.csv
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
icao,iata,name,location,country,timezone,hub,lat,lon,ground_handling_cost,fuel_100ll_cost,fuel_jeta_cost,fuel_mogas_cost,notes
EGLL,LHR,"London Heathrow","London, England",,Europe/London,,51.4775,-0.4614,500,0,0,0,
KAUS,AUS,Austin-Bergstrom,"Austin, Texas, USA","United States",America/Chicago,1,30.1945,-97.6699,0,0,0,0,"Test Note"
KJFK,JFK,"John F Kennedy","New York, New York, USA","United States",America/New_York,1,40.6399,-73.7787,250,0,0,0,"Busy Airport"
KPAE,PAE,"Snohomish County (Paine Field) Airport",Everett,"United States",America/Los_Angeles,,47.9063,-122.282,0,0,0,0,
KSEA,SEA,"Seattle Tacoma International Airport",Seattle,"United States",America/Los_Angeles,,47.449,-122.309,0,0,0,0,
LEMD,MAD,"Adolfo Suárez Madrid–Barajas Airport",Madrid,Spain,Europe/Madrid,,40.4719,-3.5626,,0,0,0,
MKJP,KIN,"Norman Manley International Airport","Kingston, Jamaica",,America/Jamaica,,17.9357,-76.7875,50,0,0,0,
MWCR,GCM,"Owen Roberts International Airport",Georgetown,Cayman,America/Cayman,,19.2928,-81.3577,50,0,0,0,
OMDB,DXB,"Dubai International Airport","Dubai, UAE",,Asia/Dubai,,25.2528,55.3644,50,0,0,0,
icao,iata,name,location,region,country,timezone,hub,lat,lon,elevation,ground_handling_cost,fuel_100ll_cost,fuel_jeta_cost,fuel_mogas_cost,notes
EGLL,LHR,"London Heathrow","London, England",,,Europe/London,,51.4775,-0.4614,-156,500,0,0,0,
KAUS,AUS,Austin-Bergstrom,"Austin, Texas, USA","Texas","United States",America/Chicago,1,30.1945,-97.6699,,0,0,0,0,"Test Note"
KJFK,JFK,"John F Kennedy","New York, New York, USA","New York","United States",America/New_York,1,40.6399,-73.7787,,250,0,0,0,"Busy Airport"
KPAE,PAE,"Snohomish County (Paine Field) Airport",Everett,,"United States",America/Los_Angeles,,47.9063,-122.282,,0,0,0,0,
KSEA,SEA,"Seattle Tacoma International Airport",Seattle,,"United States",America/Los_Angeles,,47.449,-122.309,,0,0,0,0,
LEMD,MAD,"Adolfo Suárez Madrid–Barajas Airport",Madrid,,Spain,Europe/Madrid,,40.4719,-3.5626,,,0,0,0,
MKJP,KIN,"Norman Manley International Airport","Kingston, Jamaica",,,America/Jamaica,,17.9357,-76.7875,98,50,0,0,0,
MWCR,GCM,"Owen Roberts International Airport",Georgetown,,Cayman,America/Cayman,,19.2928,-81.3577,459,50,0,0,0,
OMDB,DXB,"Dubai International Airport","Dubai, UAE",,,Asia/Dubai,,25.2528,55.3644,,50,0,0,0,

0 comments on commit ca4a42b

Please sign in to comment.