Field cleanup and some field details

This commit is contained in:
Nabeel Shahzad
2017-12-31 14:00:50 -06:00
parent 4cc08406fa
commit d93e461266
11 changed files with 140 additions and 89 deletions

View File

@@ -2,14 +2,16 @@
namespace App\Http\Controllers\Admin; namespace App\Http\Controllers\Admin;
use Cache;
use Flash;
use Response;
use Illuminate\Http\Request;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Http\Requests\CreateRankRequest; use App\Http\Requests\CreateRankRequest;
use App\Http\Requests\UpdateRankRequest; use App\Http\Requests\UpdateRankRequest;
use App\Repositories\RankRepository; use App\Repositories\RankRepository;
use App\Repositories\SubfleetRepository; use App\Repositories\SubfleetRepository;
use Illuminate\Http\Request;
use Flash;
use Prettus\Repository\Criteria\RequestCriteria;
use Response;
class RankController extends BaseController class RankController extends BaseController
{ {
@@ -19,8 +21,7 @@ class RankController extends BaseController
public function __construct( public function __construct(
RankRepository $rankingRepo, RankRepository $rankingRepo,
SubfleetRepository $subfleetRepo SubfleetRepository $subfleetRepo
) ) {
{
$this->rankRepository = $rankingRepo; $this->rankRepository = $rankingRepo;
$this->subfleetRepo = $subfleetRepo; $this->subfleetRepo = $subfleetRepo;
} }

View File

@@ -2,19 +2,20 @@
namespace App\Http\Controllers\Admin; namespace App\Http\Controllers\Admin;
use App\Http\Requests;
use App\Models\Airline;
use App\Models\Subfleet;
use App\Http\Requests\CreateSubfleetRequest;
use App\Http\Requests\UpdateSubfleetRequest;
use App\Models\Fare;
use App\Repositories\FareRepository;
use App\Repositories\SubfleetRepository;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Flash; use Flash;
use Prettus\Repository\Criteria\RequestCriteria; use Prettus\Repository\Criteria\RequestCriteria;
use Response; use Response;
use App\Models\Enums\FuelType;
use App\Models\Airline;
use App\Models\Subfleet;
use App\Http\Requests\CreateSubfleetRequest;
use App\Http\Requests\UpdateSubfleetRequest;
use App\Repositories\FareRepository;
use App\Repositories\SubfleetRepository;
class SubfleetController extends BaseController class SubfleetController extends BaseController
{ {
/** @var SubfleetRepository */ /** @var SubfleetRepository */
@@ -34,19 +35,6 @@ class SubfleetController extends BaseController
$this->fareRepo = $fareRepo; $this->fareRepo = $fareRepo;
} }
/**
* @return array
*/
protected function getFuelTypes()
{
$retval = [];
foreach (config('enums.fuel_types') as $fuel_type => $value) {
$retval[$value] = $fuel_type;
}
return $retval;
}
/** /**
* Get all the fares that haven't been assigned to a given subfleet * Get all the fares that haven't been assigned to a given subfleet
*/ */
@@ -67,9 +55,9 @@ class SubfleetController extends BaseController
/** /**
* Display a listing of the Subfleet. * Display a listing of the Subfleet.
*
* @param Request $request * @param Request $request
* @return Response * @return Response
* @throws \Prettus\Repository\Exceptions\RepositoryException
*/ */
public function index(Request $request) public function index(Request $request)
{ {
@@ -90,7 +78,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(), 'fuel_types' => FuelType::labels(),
]); ]);
} }
@@ -152,9 +140,9 @@ 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(), 'fuel_types' => FuelType::labels(),
'avail_fares' => $avail_fares, 'avail_fares' => $avail_fares,
'subfleet' => $subfleet, 'subfleet' => $subfleet,
]); ]);
} }

View File

@@ -41,4 +41,21 @@ class EnumBase
return $labels; return $labels;
} }
/**
* Select box
*/
public static function select($add_blank=false)
{
$labels = [];
if($add_blank) {
$labels[] = '';
}
foreach (static::$labels as $key => $label) {
$labels[$key] = trans($label);
}
return $labels;
}
} }

View File

@@ -0,0 +1,16 @@
<?php
namespace App\Models\Enums;
class FuelType extends EnumBase {
const LOW_LEAD = 0;
const JET_A = 1;
const MOGAS = 2;
protected static $labels = [
FuelType::LOW_LEAD => '100LL',
FuelType::JET_A => 'JET A',
FuelType::MOGAS => 'MOGAS',
];
}

View File

@@ -34,10 +34,6 @@ class AcarsRepository extends BaseRepository //implements CacheableInterface
return Pirep::with(['airline', 'position']) return Pirep::with(['airline', 'position'])
->where(['state' => PirepState::IN_PROGRESS]) ->where(['state' => PirepState::IN_PROGRESS])
->get(); ->get();
/*return Pirep::with(['acars' => function($q) {
return $q->limit(1);
}])->where(['state' => PirepState::IN_PROGRESS])->get();*/
} }
/** /**

View File

@@ -85,3 +85,10 @@
.table-upgrade td:nth-child(3) { .table-upgrade td:nth-child(3) {
text-align: center; text-align: center;
} }
span.required {
color: #c12e2a;
font-weight: 400;
font-size: 120%;
vertical-align: sub;
}

View File

@@ -1,22 +1,12 @@
@extends('admin.app') @extends('admin.app')
@section('title', 'Add Aircraft') @section('title', 'Add Aircraft')
@section('content') @section('content')
<section class="content-header"> <div class="card border-blue-bottom">
<h1>Aircraft</h1> <div class="content">
</section>
<div class="content">
@include('admin.flash.message') @include('admin.flash.message')
<div class="box box-primary"> {!! Form::open(['route' => 'admin.aircraft.store']) !!}
@include('admin.aircraft.fields')
<div class="box-body"> {!! Form::close() !!}
<div class="row">
{!! Form::open(['route' => 'admin.aircraft.store']) !!}
@include('admin.aircraft.fields')
{!! Form::close() !!}
</div>
</div>
</div> </div>
</div> </div>
@endsection @endsection

View File

@@ -1,41 +1,44 @@
<div class="row"> <div class="row">
<!-- Name Field --> <!-- Name Field -->
<div class="form-group col-sm-6"> <div class="form-group col-sm-6">
{!! Form::label('name', 'Name:') !!} {!! Form::label('name', 'Name:') !!} <span class="required">*</span>
{!! Form::text('name', null, ['class' => 'form-control']) !!} {!! Form::text('name', null, ['class' => 'form-control']) !!}
</div> </div>
<div class="form-group col-sm-6"> <div class="form-group col-sm-6">
{!! Form::label('subfleet_id', 'Subfleet:') !!} {!! Form::label('subfleet_id', 'Subfleet:') !!}
{!! Form::select('subfleet_id', $subfleets, null, ['class' => 'form-control select2', 'placeholder' => 'Select Subfleet']) !!} {!! Form::select('subfleet_id', $subfleets, null, ['class' => 'form-control select2', 'placeholder' => 'Select Subfleet']) !!}
</div> </div>
<!-- Registration Field -->
<div class="form-group col-sm-6">
{!! Form::label('registration', 'Registration:') !!}
{!! Form::text('registration', null, ['class' => 'form-control']) !!}
</div> </div>
<div class="row">
<!-- Registration Field -->
<div class="form-group col-sm-6">
{!! Form::label('registration', 'Registration:') !!}
{!! Form::text('registration', null, ['class' => 'form-control']) !!}
</div>
<!-- Tail Number Field --> <!-- Tail Number Field -->
<div class="form-group col-sm-6"> <div class="form-group col-sm-6">
{!! Form::label('tail_number', 'Tail Number:') !!} {!! Form::label('tail_number', 'Tail Number:') !!}
{!! Form::text('tail_number', null, ['class' => 'form-control']) !!} {!! Form::text('tail_number', null, ['class' => 'form-control']) !!}
</div>
<!-- Active Field -->
<div class="form-group col-12">
{!! Form::label('active', 'Active:') !!}
<label class="checkbox-inline">
{!! Form::hidden('active', 0, false) !!}
{!! Form::checkbox('active', 1, null) !!}
</label>
</div>
<!-- Submit Field -->
<div class="form-group col-sm-12">
<div class="pull-right">
{!! Form::submit('Save', ['class' => 'btn btn-primary']) !!}
<a href="{!! route('admin.aircraft.index') !!}" class="btn btn-default">Cancel</a>
</div> </div>
</div> </div>
<div class="row">
<!-- Active Field -->
<div class="form-group col-12">
{!! Form::label('active', 'Active:') !!}
<label class="checkbox-inline">
{!! Form::hidden('active', 0, false) !!}
{!! Form::checkbox('active', 1, null) !!}
</label>
</div>
<!-- Submit Field -->
<div class="form-group col-sm-12">
<div class="pull-right">
{!! Form::submit('Save', ['class' => 'btn btn-primary']) !!}
<a href="{!! route('admin.aircraft.index') !!}" class="btn btn-default">Cancel</a>
</div>
</div>
</div> </div>

View File

@@ -1,31 +1,64 @@
<div class="row">
<div class="col-md-12">
<div class="callout callout-success">
When a fare is assigned to a subfleet, the price, cost and capacity can be overridden,
so you can create default values that will apply to most of your subfleets, and change
them where they will differ.
</div>
<br />
</div>
</div>
<div class="row"> <div class="row">
<div class="form-group col-sm-6"> <div class="form-group col-sm-6">
{!! Form::label('code', 'Code:') !!} {!! Form::label('code', 'Code:') !!}
<div class="callout callout-info">
<i class="icon fa fa-info">&nbsp;&nbsp;</i>
How this fare class will show up on a ticket
</div>
{!! Form::text('code', null, ['class' => 'form-control']) !!} {!! Form::text('code', null, ['class' => 'form-control']) !!}
</div> </div>
<div class="form-group col-sm-6"> <div class="form-group col-sm-6">
{!! Form::label('name', 'Name:') !!} {!! Form::label('name', 'Name:') !!}
<div class="callout callout-info">
<i class="icon fa fa-info">&nbsp;&nbsp;</i>
The fare class name, E.g, "Economy" or "First"
</div>
{!! Form::text('name', null, ['class' => 'form-control']) !!} {!! Form::text('name', null, ['class' => 'form-control']) !!}
</div> </div>
<div class="form-group col-sm-6"> <div class="form-group col-sm-6">
{!! Form::label('price', 'Price:') !!} {!! Form::label('price', 'Price:') !!}
<div class="callout callout-info">
<i class="icon fa fa-info">&nbsp;&nbsp;</i>
This is the price of a ticket for a passenger
</div>
{!! Form::text('price', null, ['class' => 'form-control']) !!} {!! Form::text('price', null, ['class' => 'form-control']) !!}
</div> </div>
<div class="form-group col-sm-6"> <div class="form-group col-sm-6">
{!! Form::label('cost', 'Cost:') !!} {!! Form::label('cost', 'Cost:') !!}
<div class="callout callout-info">
<i class="icon fa fa-info">&nbsp;&nbsp;</i>
The operating cost
</div>
{!! Form::text('cost', null, ['class' => 'form-control']) !!} {!! Form::text('cost', null, ['class' => 'form-control']) !!}
</div> </div>
<div class="form-group col-sm-6"> <div class="form-group col-sm-6">
{!! Form::label('capacity', 'Capacity:') !!} {!! Form::label('capacity', 'Capacity:') !!}
<div class="callout callout-info">
<i class="icon fa fa-info">&nbsp;&nbsp;</i>
The number of seats available in this class.
</div>
{!! Form::text('capacity', null, ['class' => 'form-control']) !!} {!! Form::text('capacity', null, ['class' => 'form-control']) !!}
</div> </div>
<div class="form-group col-sm-6"> <div class="form-group col-sm-6">
{!! Form::label('notes', 'Notes:') !!} {!! Form::label('notes', 'Notes:') !!}
<div class="callout callout-info">
&nbsp;
</div>
{!! Form::text('notes', null, ['class' => 'form-control']) !!} {!! Form::text('notes', null, ['class' => 'form-control']) !!}
</div> </div>

View File

@@ -17,7 +17,7 @@
<p>{!! $subfleet->type !!}</p> <p>{!! $subfleet->type !!}</p>
</div> </div>
<!-- Fuel Type Field --> {{--<!-- Fuel Type Field -->
<div class="form-group"> <div class="form-group">
{!! Form::label('fuel_type', 'Fuel Type:') !!} {!! Form::label('fuel_type', 'Fuel Type:') !!}
<p> <p>
@@ -31,7 +31,7 @@
- -
@endif @endif
</p> </p>
</div> </div>--}}
<!-- Created At Field --> <!-- Created At Field -->
<div class="form-group"> <div class="form-group">

View File

@@ -4,7 +4,7 @@
<th>Airline</th> <th>Airline</th>
<th>Name</th> <th>Name</th>
<th>Type</th> <th>Type</th>
<th>Fuel Type</th> {{--<th>Fuel Type</th>--}}
<th></th> <th></th>
</thead> </thead>
<tbody> <tbody>
@@ -13,7 +13,7 @@
<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> {{--<td>
@if($subfleet->fuel_type === config('enums.fuel_types.100LL')) @if($subfleet->fuel_type === config('enums.fuel_types.100LL'))
100LL 100LL
@elseif($subfleet->fuel_type === config('enums.fuel_types.JETA')) @elseif($subfleet->fuel_type === config('enums.fuel_types.JETA'))
@@ -23,7 +23,7 @@
@else @else
- -
@endif @endif
</td> </td>--}}
<td class="text-right"> <td class="text-right">
{!! Form::open(['route' => ['admin.subfleets.destroy', $subfleet->id], 'method' => 'delete']) !!} {!! Form::open(['route' => ['admin.subfleets.destroy', $subfleet->id], 'method' => 'delete']) !!}