diff --git a/app/Http/Controllers/Admin/PirepController.php b/app/Http/Controllers/Admin/PirepController.php
index 6536fdca..6baf2afc 100644
--- a/app/Http/Controllers/Admin/PirepController.php
+++ b/app/Http/Controllers/Admin/PirepController.php
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
use App\Http\Requests\CreatePirepRequest;
use App\Http\Requests\UpdatePirepRequest;
+use App\Repositories\AircraftRepository;
use App\Repositories\PirepRepository;
use Illuminate\Http\Request;
use Flash;
@@ -12,11 +13,24 @@ use Response;
class PirepController extends BaseController
{
- private $pirepRepository;
+ private $pirepRepo, $aircraftRepo;
- public function __construct(PirepRepository $pirepRepo)
+ public function __construct(PirepRepository $pirepRepo, AircraftRepository $aircraftRepo)
{
- $this->pirepRepository = $pirepRepo;
+ $this->aircraftRepo = $aircraftRepo;
+ $this->pirepRepo = $pirepRepo;
+ }
+
+ public function aircraftList()
+ {
+ $retval = [];
+ $all_aircraft = $this->aircraftRepo->all();
+
+ foreach ($all_aircraft as $ac) {
+ $retval[$ac->id] = $ac->subfleet->name.' - '.$ac->name.' ('.$ac->registration.')';
+ }
+
+ return $retval;
}
/**
@@ -27,8 +41,8 @@ class PirepController extends BaseController
*/
public function index(Request $request)
{
- $this->pirepRepository->pushCriteria(new RequestCriteria($request));
- $pireps = $this->pirepRepository->all();
+ $this->pirepRepo->pushCriteria(new RequestCriteria($request));
+ $pireps = $this->pirepRepo->all();
return view('admin.pireps.index', [
'pireps' => $pireps
@@ -55,7 +69,7 @@ class PirepController extends BaseController
public function store(CreatePirepRequest $request)
{
$input = $request->all();
- $pirep = $this->pirepRepository->create($input);
+ $pirep = $this->pirepRepo->create($input);
Flash::success('Pirep saved successfully.');
return redirect(route('admin.pireps.index'));
@@ -70,7 +84,7 @@ class PirepController extends BaseController
*/
public function show($id)
{
- $pirep = $this->pirepRepository->findWithoutFail($id);
+ $pirep = $this->pirepRepo->findWithoutFail($id);
if (empty($pirep)) {
Flash::error('Pirep not found');
@@ -91,7 +105,7 @@ class PirepController extends BaseController
*/
public function edit($id)
{
- $pirep = $this->pirepRepository->findWithoutFail($id);
+ $pirep = $this->pirepRepo->findWithoutFail($id);
if (empty($pirep)) {
Flash::error('Pirep not found');
@@ -100,6 +114,7 @@ class PirepController extends BaseController
return view('admin.pireps.edit', [
'pirep' => $pirep,
+ 'aircraft' => $this->aircraftList(),
]);
}
@@ -113,14 +128,14 @@ class PirepController extends BaseController
*/
public function update($id, UpdatePirepRequest $request)
{
- $pirep = $this->pirepRepository->findWithoutFail($id);
+ $pirep = $this->pirepRepo->findWithoutFail($id);
if (empty($pirep)) {
Flash::error('Pirep not found');
return redirect(route('admin.pireps.index'));
}
- $pirep = $this->pirepRepository->update($request->all(), $id);
+ $pirep = $this->pirepRepo->update($request->all(), $id);
Flash::success('Pirep updated successfully.');
return redirect(route('admin.pireps.index'));
@@ -135,14 +150,14 @@ class PirepController extends BaseController
*/
public function destroy($id)
{
- $pirep = $this->pirepRepository->findWithoutFail($id);
+ $pirep = $this->pirepRepo->findWithoutFail($id);
if (empty($pirep)) {
Flash::error('Pirep not found');
return redirect(route('admin.pireps.index'));
}
- $this->pirepRepository->delete($id);
+ $this->pirepRepo->delete($id);
Flash::success('Pirep deleted successfully.');
return redirect(route('admin.pireps.index'));
diff --git a/app/Models/PirepFieldValues.php b/app/Models/PirepFieldValues.php
index e18a3b18..06313295 100644
--- a/app/Models/PirepFieldValues.php
+++ b/app/Models/PirepFieldValues.php
@@ -30,7 +30,7 @@ class PirepFieldValues extends Model
= [
'name' => 'string',
'value' => 'string',
- 'source' => 'integer',
+ 'source' => 'string',
];
/**
diff --git a/database/migrations/2017_06_28_195426_create_pireps_table.php b/database/migrations/2017_06_28_195426_create_pireps_table.php
index 0515e021..419ef7be 100644
--- a/database/migrations/2017_06_28_195426_create_pireps_table.php
+++ b/database/migrations/2017_06_28_195426_create_pireps_table.php
@@ -77,7 +77,7 @@ class CreatePirepsTable extends Migration
$table->uuid('pirep_id');
$table->string('name', 50);
$table->text('value');
- $table->tinyInteger('source')->default(0);
+ $table->string('source')->nullable();
$table->timestamps();
$table->index('pirep_id');
diff --git a/database/seeds/dev.yml b/database/seeds/dev.yml
index b8ebb262..121c1f88 100644
--- a/database/seeds/dev.yml
+++ b/database/seeds/dev.yml
@@ -160,7 +160,8 @@ flight_fields:
value: B
pireps:
- - user_id: 1
+ - id: pirepid_1
+ user_id: 1
flight_id: flightid_1
aircraft_id: 1
dpt_airport_id: 1
@@ -169,3 +170,15 @@ pireps:
level: 320
status: -1
notes: just a pilot report
+
+pirep_fields:
+ - id: 1
+ name: arrival gate
+ required: 0
+
+pirep_field_values:
+ - id: 1
+ pirep_id: pirepid_1
+ name: arrival gate
+ value: B14
+ source: manual
diff --git a/resources/views/admin/pireps/field_values.blade.php b/resources/views/admin/pireps/field_values.blade.php
new file mode 100644
index 00000000..e73e2430
--- /dev/null
+++ b/resources/views/admin/pireps/field_values.blade.php
@@ -0,0 +1,35 @@
+
+
+
+ Name |
+ Value |
+ Source |
+ Actions |
+
+
+ @foreach($pirep->fields as $field)
+
+ {!! $field->name !!} |
+
+ {!! $field->value !!}
+ |
+ {!! $field->source !!} |
+
+ {!! Form::open(['url' => '/admin/pireps/'.$pirep->id.'/fields',
+ 'method' => 'delete',
+ 'class' => 'pjax_form pirep_fields'
+ ]) !!}
+ {!! Form::hidden('field_id', $field->id) !!}
+
+ {{--{!! Form::button('',
+ ['type' => 'submit',
+ 'class' => 'btn btn-danger btn-xs'])
+ !!}--}}
+
+ {!! Form::close() !!}
+ |
+
+ @endforeach
+
+
+
diff --git a/resources/views/admin/pireps/fields.blade.php b/resources/views/admin/pireps/fields.blade.php
index f5e1d2f8..a39d3b32 100644
--- a/resources/views/admin/pireps/fields.blade.php
+++ b/resources/views/admin/pireps/fields.blade.php
@@ -1,13 +1,13 @@
---}}
{!! Form::label('aircraft_id', 'Aircraft ID:') !!}
- {!! Form::text('aircraft_id', null, ['class' => 'form-control']) !!}
+ {!! Form::select('aircraft_id', $aircraft, null, ['class' => 'form-control']) !!}
diff --git a/resources/views/admin/pireps/show.blade.php b/resources/views/admin/pireps/show.blade.php
index 2c197c5d..1c924412 100644
--- a/resources/views/admin/pireps/show.blade.php
+++ b/resources/views/admin/pireps/show.blade.php
@@ -1,17 +1,23 @@
@extends('admin.app')
@section('content')
-
-
-
-
-
- @include('admin.pireps.show_fields')
-
Back
+
+
+
+
+ @include('admin.pireps.show_fields')
+
+
+
+
+
+
fields
+
+ @include('admin.pireps.field_values')
+
+
@endsection
diff --git a/resources/views/admin/pireps/show_fields.blade.php b/resources/views/admin/pireps/show_fields.blade.php
index 01878f16..fb28393a 100644
--- a/resources/views/admin/pireps/show_fields.blade.php
+++ b/resources/views/admin/pireps/show_fields.blade.php
@@ -1,66 +1,100 @@
-
-