#21 PIREP submit form first pass

This commit is contained in:
Nabeel Shahzad 2017-08-16 18:18:47 -05:00
parent 09502153ed
commit f739cd0a67
5 changed files with 172 additions and 7 deletions

View File

@ -3,14 +3,56 @@
namespace App\Http\Controllers\Frontend; namespace App\Http\Controllers\Frontend;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\AppBaseController; use Illuminate\Http\Request;
use App\Models\Airline;
use App\Models\Airport;
use App\Models\Pirep; use App\Models\Pirep;
use App\Models\PirepField;
use App\Http\Controllers\Controller;
use App\Repositories\AirlineRepository;
use App\Repositories\AircraftRepository;
use App\Repositories\PirepRepository;
class PirepController extends AppBaseController class PirepController extends Controller
{ {
public function index() public function __construct(
AirlineRepository $airlineRepo,
PirepRepository $pirepRepo,
AircraftRepository $aircraftRepo)
{
$this->airlineRepo = $airlineRepo;
$this->aircraftRepo = $aircraftRepo;
$this->pirepRepo = $pirepRepo;
}
public function airportList()
{
# TODO: Cache
$retval = [];
$airports = Airport::all();
foreach($airports as $airport) {
$retval[$airport->id] = $airport->icao.' - '.$airport->name;
}
return $retval;
}
public function aircraftList()
{
$retval = [];
$aircraft = $this->aircraftRepo->all();
foreach ($aircraft as $ac) {
$retval[$ac->id] = $ac->subfleet->name.' - '.$ac->name.' ('.$ac->registration.')';
}
return $retval;
}
public function index(Request $request)
{ {
$user = Auth::user(); $user = Auth::user();
$pireps = Pirep::where('user_id', $user->id) $pireps = Pirep::where('user_id', $user->id)
@ -25,10 +67,17 @@ class PirepController extends AppBaseController
public function create() public function create()
{ {
return $this->view('pireps.create'); $airports = $this->airportList();
return $this->view('pireps.create', [
'airports' => $airports,
'airlines' => Airline::all()->pluck('name', 'id'),
'aircraft' => $this->aircraftList(),
'pirepfields' => PirepField::all(),
'fieldvalues' => [],
]);
} }
public function store() public function store(Request $request)
{ {
} }

View File

@ -15,6 +15,7 @@
href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css"/> href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css"/>
<!-- CSS Files --> <!-- CSS Files -->
<link href="/assets/frontend/css/bootstrap.min.css" rel="stylesheet"/> <link href="/assets/frontend/css/bootstrap.min.css" rel="stylesheet"/>
<link href="/vendor/select2/dist/css/select2.min.css" rel="stylesheet"/>
<link href="/assets/frontend/css/now-ui-kit.css" rel="stylesheet"/> <link href="/assets/frontend/css/now-ui-kit.css" rel="stylesheet"/>
<link href="/assets/frontend/css/styles.css" rel="stylesheet"/> <link href="/assets/frontend/css/styles.css" rel="stylesheet"/>
@ -131,6 +132,12 @@
<script src="/assets/frontend/js/plugins/nouislider.min.js" type="text/javascript"></script> <script src="/assets/frontend/js/plugins/nouislider.min.js" type="text/javascript"></script>
<script src="/assets/frontend/js/plugins/bootstrap-datepicker.js" type="text/javascript"></script> <script src="/assets/frontend/js/plugins/bootstrap-datepicker.js" type="text/javascript"></script>
<script src="/assets/frontend/js/now-ui-kit.js" type="text/javascript"></script> <script src="/assets/frontend/js/now-ui-kit.js" type="text/javascript"></script>
<script src="/vendor/select2/dist/js/select2.js"></script>
<script>
$(document).ready(function () {
$(".select2").select2();
});
</script>
@yield('scripts') @yield('scripts')

View File

@ -0,0 +1,22 @@
@extends('layouts.default.app')
@section('content')
<div class="row">
<div class="col-md-12">
<h2 class="description">new pilot report</h2>
@include('flash::message')
{!! Form::open(['route' => 'frontend.pireps.store']) !!}
@include('layouts.default.pireps.fields')
{!! Form::close() !!}
</div>
</div>
@endsection
@section('scripts')
<script>
$(document).ready(function() {
});
</script>
@endsection

View File

@ -0,0 +1,87 @@
<!-- Flight Id Field -->
{{--<div class="form-group col-sm-6">
{!! Form::label('flight_id', 'Flight ID:') !!}
{!! Form::text('flight_id', null, ['class' => 'form-control']) !!}
</div>--}}
<div class="row">
<div class="col-sm-6">
<p class="description">Airline</p>
<div class="input-group form-group">
{!! Form::select('airline_id', $airlines, null, ['class' => 'custom-select select2']) !!}
</div>
<p class="description">Aircraft</p>
<div class="input-group form-group">
{!! Form::select('aircraft_id', $aircraft, null, ['class' => 'custom-select select2']) !!}
</div>
<p class="description">Origin Airport</p>
<div class="input-group form-group">
{!! Form::select('dep_airport_id', $airports, null, ['class' => 'custom-select select2']) !!}
</div>
<p class="description">Arrival Airport</p>
<div class="input-group form-group">
{!! Form::select('arr_airport_id', $airports, null, ['class' => 'custom-select select2']) !!}
</div>
<!-- Flight Time Field -->
<p class="description">Flight Time</p>
<div class="input-group form-group-no-border">
{!! Form::text('hours', null, ['class' => 'form-control', 'placeholder' => 'hours']) !!}
</div>
<div class="input-group form-group-no-border">
{!! Form::text('minutes', null, ['class' => 'form-control', 'placeholder' => 'minutes']) !!}
</div>
<!-- Level Field -->
<p class="description">Flight Level</p>
<div class="input-group form-group">
<span class="input-group-addon">
<i class="now-ui-icons users_single-02"></i>
</span>
{!! Form::number('level', null, ['class' => 'form-control', 'placeholder' => 'Flight Level']) !!}
</div>
<!-- Route Field -->
<p class="description">Route</p>
<div class="input-group form-group">
{!! Form::textarea('route', null, ['class' => 'form-control', 'placeholder' => 'Route']) !!}
</div>
</div>
<div class="col-sm-6">
<!-- optional fields -->
@foreach($pirepfields as $field)
<p class="description text-uppercase">{!! $field->name !!}</p>
<div class="input-group form-group">
<!--<span class="input-group-addon">
<i class="now-ui-icons users_single-02"></i>
</span>-->
{!! Form::text('field_'.$field->id, null, [
'class' => 'form-control',
'required' => $field->required,
]) !!}
</div>
@endforeach
<p class="description">Notes</p>
<div class="input-group form-group">
{!! Form::textarea('notes', null, ['class' => 'form-control', 'placeholder' => 'Notes']) !!}
</div>
</div>
<div class="col-sm-12">
<div class="float-right">
<div class="form-group">
{!! Form::submit('Submit PIREP', ['class' => 'btn btn-primary']) !!}
</div>
</div>
</div>
</div>

View File

@ -8,8 +8,8 @@ Route::get('/', 'HomeController@index');
Route::group([ Route::group([
'namespace' => 'Frontend', 'prefix' => '', 'as' => 'frontend.' 'namespace' => 'Frontend', 'prefix' => '', 'as' => 'frontend.'
], function() { ], function() {
Route::get('/pireps/{id}', 'PirepController@show'); Route::get('/r/{id}', 'PirepController@show');
Route::get('/profile/{id}', 'ProfileController@show'); Route::get('/p/{id}', 'ProfileController@show');
}); });
/** /**