diff --git a/app/Http/Controllers/Admin/SubfleetController.php b/app/Http/Controllers/Admin/SubfleetController.php index 6fcc8b52..8d930ef3 100644 --- a/app/Http/Controllers/Admin/SubfleetController.php +++ b/app/Http/Controllers/Admin/SubfleetController.php @@ -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, ]); diff --git a/app/Models/Subfleet.php b/app/Models/Subfleet.php index 1586487e..318c0a1c 100644 --- a/app/Models/Subfleet.php +++ b/app/Models/Subfleet.php @@ -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', ]; /** diff --git a/database/migrations/2017_06_23_011011_create_subfleets_table.php b/database/migrations/2017_06_23_011011_create_subfleets_table.php index 10cebcf8..ff9331fa 100644 --- a/database/migrations/2017_06_23_011011_create_subfleets_table.php +++ b/database/migrations/2017_06_23_011011_create_subfleets_table.php @@ -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(); }); diff --git a/resources/views/admin/app.blade.php b/resources/views/admin/app.blade.php index f2048764..16fb5fc9 100644 --- a/resources/views/admin/app.blade.php +++ b/resources/views/admin/app.blade.php @@ -194,6 +194,11 @@ {{-- --}} + @yield('scripts') diff --git a/resources/views/admin/subfleets/fields.blade.php b/resources/views/admin/subfleets/fields.blade.php index b793e1b3..120dab9c 100644 --- a/resources/views/admin/subfleets/fields.blade.php +++ b/resources/views/admin/subfleets/fields.blade.php @@ -1,21 +1,27 @@ -
+
{!! 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']) !!}
-
+
{!! Form::label('name', 'Name:') !!} {!! Form::text('name', null, ['class' => 'form-control']) !!}
-
+
{!! Form::label('type', 'Type:') !!} {!! Form::text('type', null, ['class' => 'form-control']) !!}
+ +
+ {!! Form::label('fuel_type', 'Fuel Type:') !!} + {!! Form::select('fuel_type', $fuel_types, null , ['class' => 'form-control select2']) !!} +
+
diff --git a/resources/views/admin/subfleets/show_fields.blade.php b/resources/views/admin/subfleets/show_fields.blade.php index db519360..1ad1afd2 100644 --- a/resources/views/admin/subfleets/show_fields.blade.php +++ b/resources/views/admin/subfleets/show_fields.blade.php @@ -17,6 +17,22 @@

{!! $subfleet->type !!}

+ +
+ {!! Form::label('fuel_type', 'Fuel Type:') !!} +

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

+
+
{!! Form::label('created_at', 'Created At:') !!} diff --git a/resources/views/admin/subfleets/table.blade.php b/resources/views/admin/subfleets/table.blade.php index fa6ea8ab..70716e5d 100644 --- a/resources/views/admin/subfleets/table.blade.php +++ b/resources/views/admin/subfleets/table.blade.php @@ -3,6 +3,7 @@ Airline Name Type + Fuel Type Action @@ -11,6 +12,17 @@ {!! $subfleet->airline->name !!} {!! $subfleet->name !!} {!! $subfleet->type !!} + + @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 + {!! Form::open(['route' => ['admin.subfleets.destroy', $subfleet->id], 'method' => 'delete']) !!}