cleanup aircraft table/repo
This commit is contained in:
3
Makefile
3
Makefile
@@ -18,10 +18,11 @@ install: db
|
||||
echo ""
|
||||
|
||||
clean:
|
||||
@php artisan cache:clear
|
||||
@php artisan optimize
|
||||
@php artisan route:clear
|
||||
@php artisan config:clear
|
||||
@rm -f database/testing.sqlite
|
||||
@rm -f database/*.sqlite
|
||||
|
||||
reset: clean
|
||||
@sqlite3 database/testing.sqlite ""
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin;
|
||||
use App\Models\Subfleet;
|
||||
use App\Http\Requests\CreateAircraftRequest;
|
||||
use App\Http\Requests\UpdateAircraftRequest;
|
||||
use App\Repositories\AircraftRepository;
|
||||
use App\Repositories\SubfleetRepository;
|
||||
use App\Repositories\FareRepository;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -18,7 +19,7 @@ class AircraftController extends BaseController
|
||||
private $aircraftRepository, $fareRepository;
|
||||
|
||||
public function __construct(
|
||||
SubfleetRepository $aircraftRepo,
|
||||
AircraftRepository $aircraftRepo,
|
||||
FareRepository $fareRepo
|
||||
) {
|
||||
$this->fareRepository = $fareRepo;
|
||||
@@ -106,8 +107,8 @@ class AircraftController extends BaseController
|
||||
return redirect(route('admin.aircraft.index'));
|
||||
}
|
||||
|
||||
// print_r($request->toArray());
|
||||
$aircraft = $this->aircraftRepository->update($request->all(), $id);
|
||||
|
||||
Flash::success('Aircraft updated successfully.');
|
||||
return redirect(route('admin.aircraft.index'));
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class Aircraft extends Model
|
||||
public $fillable
|
||||
= [
|
||||
'subfleet_id',
|
||||
'icao',
|
||||
'airport_id',
|
||||
'name',
|
||||
'registration',
|
||||
'tail_number',
|
||||
@@ -33,7 +33,7 @@ class Aircraft extends Model
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'icao' => 'string',
|
||||
'subfleet_id' => 'string',
|
||||
'name' => 'string',
|
||||
'registration' => 'string',
|
||||
'active' => 'boolean',
|
||||
@@ -46,7 +46,6 @@ class Aircraft extends Model
|
||||
*/
|
||||
public static $rules
|
||||
= [
|
||||
'icao' => 'required|max:5',
|
||||
'name' => 'required',
|
||||
'active' => '',
|
||||
];
|
||||
@@ -54,6 +53,10 @@ class Aircraft extends Model
|
||||
/**
|
||||
* foreign keys
|
||||
*/
|
||||
public function airport()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Airport', 'airport_id');
|
||||
}
|
||||
|
||||
public function subfleet()
|
||||
{
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\AircraftClass;
|
||||
|
||||
class AircraftClassRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $fieldSearchable = [
|
||||
'class',
|
||||
'name',
|
||||
'notes'
|
||||
];
|
||||
|
||||
/**
|
||||
* Configure the Model
|
||||
**/
|
||||
public function model()
|
||||
{
|
||||
return AircraftClass::class;
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,7 @@ class AircraftRepository extends BaseRepository
|
||||
*/
|
||||
protected $fieldSearchable
|
||||
= [
|
||||
'icao',
|
||||
'name',
|
||||
'full_name',
|
||||
'registration',
|
||||
'active',
|
||||
];
|
||||
@@ -25,9 +23,4 @@ class AircraftRepository extends BaseRepository
|
||||
{
|
||||
return Aircraft::class;
|
||||
}
|
||||
|
||||
public function findByICAO($icao)
|
||||
{
|
||||
return $this->findByField('icao', $icao)->first();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,15 +10,11 @@ class CreateAircraftsTable extends Migration
|
||||
Schema::create('aircraft', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('subfleet_id')->unsigned();
|
||||
$table->integer('airport_id')->unsigned()->nullable();
|
||||
$table->string('hex_code')->nullable();
|
||||
$table->string('icao');
|
||||
$table->string('name');
|
||||
$table->string('registration')->nullable();
|
||||
$table->string('tail_number')->nullable();
|
||||
$table->double('cargo_capacity', 19, 2)->nullable();
|
||||
$table->double('fuel_capacity', 19, 2)->nullable();
|
||||
$table->double('gross_weight', 19, 2)->nullable();
|
||||
$table->tinyInteger('fuel_type')->unsigned()->nullable();
|
||||
$table->boolean('active')->default(true);
|
||||
$table->timestamps();
|
||||
|
||||
|
||||
@@ -18,6 +18,10 @@ class CreateSubfleetsTable extends Migration
|
||||
$table->integer('airline_id')->unsigned()->nullable();
|
||||
$table->string('name');
|
||||
$table->text('type');
|
||||
$table->double('cargo_capacity', 19, 2)->nullable();
|
||||
$table->double('fuel_capacity', 19, 2)->nullable();
|
||||
$table->double('gross_weight', 19, 2)->nullable();
|
||||
$table->tinyInteger('fuel_type')->unsigned()->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
@@ -74,13 +74,11 @@ airports:
|
||||
aircraft:
|
||||
- id: 1
|
||||
subfleet_id: 1
|
||||
icao: B744
|
||||
name: Boeing 747-400
|
||||
registration: NC17
|
||||
tail_number: 17
|
||||
- id: 2
|
||||
subfleet_id: 2
|
||||
icao: B772
|
||||
name: Boeing 777-200
|
||||
registration: NC20
|
||||
tail_number: 20
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
<!-- ICAO Field -->
|
||||
<div class="form-group col-sm-6">
|
||||
{!! Form::label('icao', 'ICAO:') !!} (<a class="small" href="https://www.icao.int/publications/DOC8643/Pages/Search.aspx" target="_blank">find</a>)
|
||||
{!! Form::text('icao', null, ['class' => 'form-control']) !!}
|
||||
</div>
|
||||
|
||||
<!-- Name Field -->
|
||||
<div class="form-group col-sm-6">
|
||||
{!! Form::label('name', 'Name:') !!}
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
<div class="form-group col-sm-6">
|
||||
<div class="box box-solid">
|
||||
<div class="box-header with-border">
|
||||
{{--<i class="fa fa-text-width"></i>--}}
|
||||
<h3 class="box-title">{!! Form::label('icao', 'ICAO') !!}</h3>
|
||||
<h3 class="box-title">{!! Form::label('airport_id', 'Location') !!}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<p class="lead">{!! $aircraft->icao !!}
|
||||
@if($aircraft->subfleet)
|
||||
/{!! $aircraft->subfleet->name !!}</p>
|
||||
<p class="lead">
|
||||
@if($aircraft->airport)
|
||||
{!! $aircraft->airport->icao !!}</p>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<table class="table table-responsive" id="aircrafts-table">
|
||||
<thead>
|
||||
<th>ICAO</th>
|
||||
<th>Name</th>
|
||||
<th>Subfleet</th>
|
||||
<th>Name</th>
|
||||
<th>Registration</th>
|
||||
<th style="text-align: center;">Active</th>
|
||||
<th style="text-align: center;">Actions</th>
|
||||
@@ -10,15 +9,14 @@
|
||||
<tbody>
|
||||
@foreach($aircraft as $ac)
|
||||
<tr>
|
||||
<td><a href="{!! route('admin.aircraft.show', [$ac->id]) !!}">{!! $ac->icao !!}</a></td>
|
||||
<td>{!! $ac->name !!}</td>
|
||||
<td>
|
||||
@if($ac->subfleet)
|
||||
@if($ac->subfleet_id)
|
||||
{!! $ac->subfleet->name !!}
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
<td><a href="{!! route('admin.aircraft.show', [$ac->id]) !!}">{!! $ac->name !!}</a></td>
|
||||
<td>{!! $ac->registration !!}</td>
|
||||
<td style="text-align: center;">
|
||||
<i class="fa fa-{{$ac->active == 1?"check":""}}-square-o" aria-hidden="true"
|
||||
|
||||
Reference in New Issue
Block a user