#41 add fuel type to subfleet table

This commit is contained in:
Nabeel Shahzad 2017-07-05 09:55:36 -05:00
parent cdd315f8bb
commit e6b338cd32
7 changed files with 59 additions and 14 deletions

View File

@ -20,6 +20,16 @@ class SubfleetController extends BaseController
/** @var SubfleetRepository */
private $subfleetRepo, $fareRepo;
protected function getFuelTypes()
{
$retval = [];
foreach (config('enums.fuel_types') as $fuel_type => $value) {
$retval[$value] = $fuel_type;
}
return $retval;
}
protected function getAvailFares($subfleet)
{
$retval = [];
@ -69,6 +79,7 @@ class SubfleetController extends BaseController
{
return view('admin.subfleets.create', [
'airlines' => Airline::all()->pluck('name', 'id'),
'fuel_types' => $this->getFuelTypes(),
]);
}
@ -130,6 +141,7 @@ class SubfleetController extends BaseController
$avail_fares = $this->getAvailFares($subfleet);
return view('admin.subfleets.edit', [
'airlines' => Airline::all()->pluck('name', 'id'),
'fuel_types' => $this->getFuelTypes(),
'avail_fares' => $avail_fares,
'subfleet' => $subfleet,
]);

View File

@ -3,7 +3,6 @@
namespace App\Models;
use Eloquent as Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Subfleet
@ -11,18 +10,14 @@ use Illuminate\Database\Eloquent\SoftDeletes;
*/
class Subfleet extends Model
{
use SoftDeletes;
public $table = 'subfleets';
protected $dates = ['deleted_at'];
public $fillable = [
'airline_id',
'name',
'type'
'type',
'fuel_type',
];
/**
@ -32,8 +27,7 @@ class Subfleet extends Model
*/
protected $casts = [
'airline_id' => 'integer',
'name' => 'string',
'type' => 'string'
'fuel_type' => 'integer',
];
/**

View File

@ -18,10 +18,10 @@ class CreateSubfleetsTable extends Migration
$table->integer('airline_id')->unsigned()->nullable();
$table->string('name');
$table->text('type');
$table->tinyInteger('fuel_type')->unsigned()->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->timestamps();
$table->softDeletes();
});

View File

@ -194,6 +194,11 @@
{{-- <script src="/vendor/openlayers/ol.js"></script> --}}
<script src="/js/admin/admin.js"></script>
<script>
$(document).ready(function () {
$(".select2").select2();
});
</script>
@yield('scripts')
</body>
</html>

View File

@ -1,21 +1,27 @@
<!-- Airline Id Field -->
<div class="form-group col-sm-4">
<div class="form-group col-sm-6">
{!! Form::label('airline_id', 'Airline Id:') !!}
{!! Form::select('airline_id', $airlines, null , ['class' => 'form-control']) !!}
{!! Form::select('airline_id', $airlines, null , ['class' => 'form-control select2']) !!}
</div>
<!-- Name Field -->
<div class="form-group col-sm-4">
<div class="form-group col-sm-6">
{!! Form::label('name', 'Name:') !!}
{!! Form::text('name', null, ['class' => 'form-control']) !!}
</div>
<!-- Type Field -->
<div class="form-group col-sm-4">
<div class="form-group col-sm-6">
{!! Form::label('type', 'Type:') !!}
{!! Form::text('type', null, ['class' => 'form-control']) !!}
</div>
<!-- Fuel Type Field -->
<div class="form-group col-sm-6">
{!! Form::label('fuel_type', 'Fuel Type:') !!}
{!! Form::select('fuel_type', $fuel_types, null , ['class' => 'form-control select2']) !!}
</div>
<!-- Submit Field -->
<div class="form-group col-sm-12">
<div class="pull-right">

View File

@ -17,6 +17,22 @@
<p>{!! $subfleet->type !!}</p>
</div>
<!-- Fuel Type Field -->
<div class="form-group">
{!! Form::label('fuel_type', 'Fuel Type:') !!}
<p>
@if($subfleet->fuel_type === config('enums.fuel_types.100LL'))
100LL
@elseif($subfleet->fuel_type === config('enums.fuel_types.JETA'))
JETA
@elseif($subfleet->fuel_type === config('enums.fuel_types.MOGAS'))
MOGAS
@else
-
@endif
</p>
</div>
<!-- Created At Field -->
<div class="form-group">
{!! Form::label('created_at', 'Created At:') !!}

View File

@ -3,6 +3,7 @@
<th>Airline</th>
<th>Name</th>
<th>Type</th>
<th>Fuel Type</th>
<th colspan="3">Action</th>
</thead>
<tbody>
@ -11,6 +12,17 @@
<td>{!! $subfleet->airline->name !!}</td>
<td>{!! $subfleet->name !!}</td>
<td>{!! $subfleet->type !!}</td>
<td>
@if($subfleet->fuel_type === config('enums.fuel_types.100LL'))
100LL
@elseif($subfleet->fuel_type === config('enums.fuel_types.JETA'))
JETA
@elseif($subfleet->fuel_type === config('enums.fuel_types.MOGAS'))
MOGAS
@else
-
@endif
</td>
<td>
{!! Form::open(['route' => ['admin.subfleets.destroy', $subfleet->id], 'method' => 'delete']) !!}
<div class='btn-group'>