#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 */ /** @var SubfleetRepository */
private $subfleetRepo, $fareRepo; 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) protected function getAvailFares($subfleet)
{ {
$retval = []; $retval = [];
@ -69,6 +79,7 @@ class SubfleetController extends BaseController
{ {
return view('admin.subfleets.create', [ return view('admin.subfleets.create', [
'airlines' => Airline::all()->pluck('name', 'id'), 'airlines' => Airline::all()->pluck('name', 'id'),
'fuel_types' => $this->getFuelTypes(),
]); ]);
} }
@ -130,6 +141,7 @@ class SubfleetController extends BaseController
$avail_fares = $this->getAvailFares($subfleet); $avail_fares = $this->getAvailFares($subfleet);
return view('admin.subfleets.edit', [ return view('admin.subfleets.edit', [
'airlines' => Airline::all()->pluck('name', 'id'), 'airlines' => Airline::all()->pluck('name', 'id'),
'fuel_types' => $this->getFuelTypes(),
'avail_fares' => $avail_fares, 'avail_fares' => $avail_fares,
'subfleet' => $subfleet, 'subfleet' => $subfleet,
]); ]);

View File

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

View File

@ -18,10 +18,10 @@ class CreateSubfleetsTable extends Migration
$table->integer('airline_id')->unsigned()->nullable(); $table->integer('airline_id')->unsigned()->nullable();
$table->string('name'); $table->string('name');
$table->text('type'); $table->text('type');
$table->tinyInteger('fuel_type')->unsigned()->nullable();
$table->double('cargo_capacity', 19, 2)->nullable(); $table->double('cargo_capacity', 19, 2)->nullable();
$table->double('fuel_capacity', 19, 2)->nullable(); $table->double('fuel_capacity', 19, 2)->nullable();
$table->double('gross_weight', 19, 2)->nullable(); $table->double('gross_weight', 19, 2)->nullable();
$table->tinyInteger('fuel_type')->unsigned()->nullable();
$table->timestamps(); $table->timestamps();
$table->softDeletes(); $table->softDeletes();
}); });

View File

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

View File

@ -1,21 +1,27 @@
<!-- Airline Id Field --> <!-- Airline Id Field -->
<div class="form-group col-sm-4"> <div class="form-group col-sm-6">
{!! Form::label('airline_id', 'Airline Id:') !!} {!! 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> </div>
<!-- Name Field --> <!-- Name Field -->
<div class="form-group col-sm-4"> <div class="form-group col-sm-6">
{!! Form::label('name', 'Name:') !!} {!! Form::label('name', 'Name:') !!}
{!! Form::text('name', null, ['class' => 'form-control']) !!} {!! Form::text('name', null, ['class' => 'form-control']) !!}
</div> </div>
<!-- Type Field --> <!-- Type Field -->
<div class="form-group col-sm-4"> <div class="form-group col-sm-6">
{!! Form::label('type', 'Type:') !!} {!! Form::label('type', 'Type:') !!}
{!! Form::text('type', null, ['class' => 'form-control']) !!} {!! Form::text('type', null, ['class' => 'form-control']) !!}
</div> </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 --> <!-- Submit Field -->
<div class="form-group col-sm-12"> <div class="form-group col-sm-12">
<div class="pull-right"> <div class="pull-right">

View File

@ -17,6 +17,22 @@
<p>{!! $subfleet->type !!}</p> <p>{!! $subfleet->type !!}</p>
</div> </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 --> <!-- Created At Field -->
<div class="form-group"> <div class="form-group">
{!! Form::label('created_at', 'Created At:') !!} {!! Form::label('created_at', 'Created At:') !!}

View File

@ -3,6 +3,7 @@
<th>Airline</th> <th>Airline</th>
<th>Name</th> <th>Name</th>
<th>Type</th> <th>Type</th>
<th>Fuel Type</th>
<th colspan="3">Action</th> <th colspan="3">Action</th>
</thead> </thead>
<tbody> <tbody>
@ -11,6 +12,17 @@
<td>{!! $subfleet->airline->name !!}</td> <td>{!! $subfleet->airline->name !!}</td>
<td>{!! $subfleet->name !!}</td> <td>{!! $subfleet->name !!}</td>
<td>{!! $subfleet->type !!}</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> <td>
{!! Form::open(['route' => ['admin.subfleets.destroy', $subfleet->id], 'method' => 'delete']) !!} {!! Form::open(['route' => ['admin.subfleets.destroy', $subfleet->id], 'method' => 'delete']) !!}
<div class='btn-group'> <div class='btn-group'>