diff --git a/app/Http/Controllers/Admin/AirportController.php b/app/Http/Controllers/Admin/AirportController.php
index d5c3da56..523d8774 100644
--- a/app/Http/Controllers/Admin/AirportController.php
+++ b/app/Http/Controllers/Admin/AirportController.php
@@ -33,9 +33,10 @@ class AirportController extends InfyOmBaseController
$this->airportRepository->pushCriteria(new RequestCriteria($request));
$airports = $this->airportRepository->all();
- return view('admin.airports.index')
- ->with('airports', $airports)
- ->with('coords', ['lat' => '', 'lon' => '']);
+ return view('admin.airports.index', [
+ 'airports' => $airports,
+ 'coords' => ['lat' => '', 'lon' => ''],
+ ]);
}
/**
@@ -50,27 +51,21 @@ class AirportController extends InfyOmBaseController
/**
* Store a newly created Airport in storage.
- *
* @param CreateAirportRequest $request
- *
* @return Response
*/
public function store(CreateAirportRequest $request)
{
$input = $request->all();
-
$airport = $this->airportRepository->create($input);
Flash::success('Airport saved successfully.');
-
return redirect(route('admin.airports.index'));
}
/**
* Display the specified Airport.
- *
* @param int $id
- *
* @return Response
*/
public function show($id)
@@ -82,15 +77,14 @@ class AirportController extends InfyOmBaseController
return redirect(route('admin.airports.index'));
}
- return view('admin.airports.show')
- ->with('airport', $airport);
+ return view('admin.airports.show', [
+ 'airport' => $airport,
+ ]);
}
/**
* Show the form for editing the specified Airport.
- *
* @param int $id
- *
* @return Response
*/
public function edit($id)
@@ -99,19 +93,18 @@ class AirportController extends InfyOmBaseController
if (empty($airport)) {
Flash::error('Airport not found');
-
return redirect(route('admin.airports.index'));
}
- return view('admin.airports.edit')->with('airport', $airport);
+ return view('admin.airports.edit', [
+ 'airport' => $airport,
+ ]);
}
/**
* Update the specified Airport in storage.
- *
* @param int $id
* @param UpdateAirportRequest $request
- *
* @return Response
*/
public function update($id, UpdateAirportRequest $request)
@@ -120,22 +113,18 @@ class AirportController extends InfyOmBaseController
if (empty($airport)) {
Flash::error('Airport not found');
-
return redirect(route('admin.airports.index'));
}
$airport = $this->airportRepository->update($request->all(), $id);
Flash::success('Airport updated successfully.');
-
return redirect(route('admin.airports.index'));
}
/**
* Remove the specified Airport from storage.
- *
* @param int $id
- *
* @return Response
*/
public function destroy($id)
@@ -144,14 +133,30 @@ class AirportController extends InfyOmBaseController
if (empty($airport)) {
Flash::error('Airport not found');
-
return redirect(route('admin.airports.index'));
}
$this->airportRepository->delete($id);
Flash::success('Airport deleted successfully.');
-
return redirect(route('admin.airports.index'));
}
+
+ public function fuel(Request $request)
+ {
+ $id = $request->id;
+
+ $airport = $this->airportRepository->findWithoutFail($id);
+ if (empty($airport)) {
+ Flash::error('Flight not found');
+ return redirect(route('admin.flights.index'));
+ }
+
+ // add aircraft to flight
+ if ($request->isMethod('put')) {
+ $airport->{$request->name} = $request->value;
+ }
+
+ $airport->save();
+ }
}
diff --git a/app/Models/Airport.php b/app/Models/Airport.php
index e6fef574..2efeff83 100644
--- a/app/Models/Airport.php
+++ b/app/Models/Airport.php
@@ -11,13 +11,15 @@ use Eloquent as Model;
class Airport extends Model
{
public $table = 'airports';
-
-
protected $dates = ['deleted_at'];
-
public $fillable = [
- 'icao'
+ 'icao',
+ 'name',
+ 'location',
+ 'fuel_100ll_cost',
+ 'fuel_jeta_cost',
+ 'fuel_mogas_cost',
];
/**
diff --git a/config/enums.php b/config/enums.php
index 74213744..6f4b6ef2 100644
--- a/config/enums.php
+++ b/config/enums.php
@@ -1,6 +1,12 @@
[
+ 'INACTIVE' => 0,
+ 'ACTIVE' => 1,
+ ],
+
'sources' => [
'MANUAL' => 0,
'ACARS' => 1,
diff --git a/database/migrations/2017_06_11_135707_create_airports_table.php b/database/migrations/2017_06_11_135707_create_airports_table.php
index 8c65f933..a3e83c58 100644
--- a/database/migrations/2017_06_11_135707_create_airports_table.php
+++ b/database/migrations/2017_06_11_135707_create_airports_table.php
@@ -19,9 +19,9 @@ class CreateAirportsTable extends Migration
$table->string('name');
$table->string('location')->nullable();
$table->string('country')->nullable();
- $table->double('fuel_100ll_cost', 19, 2)->nullable();
- $table->double('fuel_jeta_cost', 19, 2)->nullable();
- $table->double('fuel_mogas_cost', 19, 2)->nullable();
+ $table->double('fuel_100ll_cost', 19, 2)->default(0);
+ $table->double('fuel_jeta_cost', 19, 2)->default(0);
+ $table->double('fuel_mogas_cost', 19, 2)->default(0);
$table->float('lat', 7, 4)->default(0.0);
$table->float('lon', 7, 4)->default(0.0);
$table->timestamps();
diff --git a/phpvms.iml b/phpvms.iml
index 2f8fcdf1..9eb8cdff 100644
--- a/phpvms.iml
+++ b/phpvms.iml
@@ -32,5 +32,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/resources/views/admin/airports/index.blade.php b/resources/views/admin/airports/index.blade.php
index 46957048..e80486b8 100644
--- a/resources/views/admin/airports/index.blade.php
+++ b/resources/views/admin/airports/index.blade.php
@@ -20,4 +20,4 @@
@endsection
-
+@include('admin.airports.script')
diff --git a/resources/views/admin/airports/script.blade.php b/resources/views/admin/airports/script.blade.php
new file mode 100644
index 00000000..2aa97e0e
--- /dev/null
+++ b/resources/views/admin/airports/script.blade.php
@@ -0,0 +1,21 @@
+@section('scripts')
+
+@endsection
diff --git a/resources/views/admin/airports/table.blade.php b/resources/views/admin/airports/table.blade.php
index df443bfb..689fd2c9 100644
--- a/resources/views/admin/airports/table.blade.php
+++ b/resources/views/admin/airports/table.blade.php
@@ -1,26 +1,40 @@
-
-
- | ICAO |
- Name |
- Location |
- Action |
-
-
- @foreach($airports as $airport)
-
- | {!! $airport->icao !!} |
- {!! $airport->name !!} |
- {!! $airport->location !!} ({!! $airport->lat !!}x{!! $airport->lon !!}) |
-
- {!! Form::open(['route' => ['admin.airports.destroy', $airport->id], 'method' => 'delete']) !!}
-
-
-
- {!! Form::button(' ', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs', 'onclick' => "return confirm('Are you sure?')"]) !!}
-
- {!! Form::close() !!}
- |
-
- @endforeach
-
-
+
+
+
+ | ICAO |
+ Name |
+ Location |
+ 100LL |
+ JetA |
+ MOGAS |
+ Action |
+
+
+ @foreach($airports as $airport)
+
+ | {!! $airport->icao !!} |
+ {!! $airport->name !!} |
+ {!! $airport->location !!} |
+
+ {!! $airport->fuel_100ll_cost !!}
+ |
+
+ {!! $airport->fuel_jeta_cost !!}
+ |
+
+ {!! $airport->fuel_mogas_cost !!}
+ |
+
+ {!! Form::open(['route' => ['admin.airports.destroy', $airport->id], 'method' => 'delete']) !!}
+
+
+
+ {!! Form::button(' ', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs', 'onclick' => "return confirm('Are you sure?')"]) !!}
+
+ {!! Form::close() !!}
+ |
+
+ @endforeach
+
+
+
diff --git a/routes/admin.php b/routes/admin.php
index 6c8f87cb..f396897f 100644
--- a/routes/admin.php
+++ b/routes/admin.php
@@ -7,8 +7,11 @@ Route::group([
'namespace' => 'Admin', 'prefix' => 'admin', 'as' => 'admin.',
'middleware' => ['role:admin'],
], function () {
- Route::resource('airports', 'AirportController');
Route::resource('airlines', 'AirlinesController');
+
+ Route::match(['get', 'put'], 'airports/fuel', 'AirportController@fuel');
+ Route::resource('airports', 'AirportController');
+
Route::resource('aircraftclasses', 'AircraftClassController');
Route::resource('fares', 'FareController');
diff --git a/tests/data/base.yml b/tests/data/base.yml
index cbb08e06..42435490 100644
--- a/tests/data/base.yml
+++ b/tests/data/base.yml
@@ -55,12 +55,14 @@ airports:
location: Austin, Texas, USA
lat: 30.1945278
lon: -97.6698889
+ fuel_jeta_cost: 100
- id: 2
icao: KJFK
name: John F Kennedy
location: New York, New York, USA
lat: 40.6399257
lon: -73.7786950
+ fuel_jeta_cost: 50
aircraft:
- id: 1
@@ -96,10 +98,12 @@ subfleets:
airline_id: 1
name: 747-400 Winglets
type: 744W
+ fuel_type: 1
- id: 2
airline_id: 1
name: 777-200 LR
type: 772-LR
+ fuel_type: 1
# add a few mods to aircraft and fares
subfleet_fare: