Major refactoring for PIREP statuses and states to accomodate ACARS/route data

This commit is contained in:
Nabeel Shahzad
2017-12-19 20:19:36 -06:00
parent ac4958a2be
commit 0375bb420f
38 changed files with 352 additions and 170 deletions

View File

@@ -8,7 +8,7 @@ use Faker\Generator as Faker;
$factory->define(App\Models\Airport::class, function (Faker $faker) {
return [
'id' => strtoupper($faker->unique()->text(5)),
'icao' => function(array $apt) { return $apt['id']; },
'icao' => function(array $apt) { return substr($apt['id'],0, 4); },
'iata' => function (array $apt) { return $apt['id']; },
'name' => $faker->sentence(3),
'country' => $faker->country,

View File

@@ -0,0 +1,15 @@
<?php
use Faker\Generator as Faker;
$factory->define(App\Models\Navpoint::class, function (Faker $faker) {
return [
'id' => $faker->unique()->numberBetween(10, 100000),
'name' => $faker->unique()->text(10),
'title' => $faker->unique()->text(25),
'airway' => $faker->unique()->text(7),
'lat' => $faker->latitude,
'lon' => $faker->longitude,
'freq' => $faker->randomFloat(2, 100, 1000),
];
});

View File

@@ -1,5 +1,7 @@
<?php
use App\Models\Enums\PirepSource;
use App\Models\Enums\PirepState;
use Faker\Generator as Faker;
# Match the list available in tests/data/*.yml
@@ -40,8 +42,8 @@ $factory->define(App\Models\Pirep::class, function (Faker $faker) use ($airlines
'flight_time' => $faker->randomFloat(2),
'route' => $faker->text(200),
'notes' => $faker->text(200),
'source' => $faker->randomElement([0, 1]), # MANUAL/ACARS
'status' => config('enums.pirep_status.PENDING'), //$faker->randomElement([-1, 0, 1]), # REJECTED/PENDING/ACCEPTED
'source' => $faker->randomElement([PirepSource::MANUAL, PirepSource::ACARS]),
'state' => PirepState::PENDING, //$faker->randomElement([-1, 0, 1]), # REJECTED/PENDING/ACCEPTED
'raw_data' => $raw_data ?: $raw_data = json_encode(['key' => 'value']),
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
'updated_at' => function(array $pirep) {

View File

@@ -29,6 +29,7 @@ class CreateUsersTable extends Migration
$table->decimal('balance', 19)->nullable();
$table->string('timezone', 64)->nullable();
$table->unsignedTinyInteger('status')->default(0);
$table->unsignedTinyInteger('state')->default(0);
$table->boolean('active')->nullable();
$table->rememberToken();
$table->timestamps();

View File

@@ -10,7 +10,7 @@ class CreateAirportsTable extends Migration
Schema::create('airports', function (Blueprint $table) {
$table->string('id', 5)->primary();
$table->string('iata', 5)->nullable();
$table->string('icao', 5);
$table->string('icao', 4);
$table->string('name', 100);
$table->string('location', 100)->nullable();
$table->string('country', 64)->nullable();

View File

@@ -30,7 +30,8 @@ class CreatePirepTables extends Migration
$table->string('route', 250)->nullable();
$table->string('notes', 250)->nullable();
$table->unsignedTinyInteger('source')->default(0);
$table->tinyInteger('status')->default(0); # -1 rejected, 0 pending, 1 accepted
$table->tinyInteger('state')->default(0); # -1 rejected, 0 pending, 1 accepted
#$table->tinyInteger('status')->default(0); # -1 rejected, 0 pending, 1 accepted
$table->longText('raw_data')->nullable();
$table->timestamps();
$table->softDeletes();

View File

@@ -0,0 +1,47 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateNavdataTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
/**
* See for defs, modify/update based on this
* https://github.com/skiselkov/openfmc/blob/master/airac.h
*/
Schema::create('navpoints', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name', 10);
$table->string('title', 25);
$table->string('airway', 7)->nullable();
$table->string('airway_type', 1)->nullable();
$table->bigInteger('seq')->nullable();
$table->string('loc', 4)->nullable();
$table->float('lat', 7, 4)->default(0.0);
$table->float('lon', 7, 4)->default(0.0);
$table->string('freq', 7);
$table->integer('type');
$table->index('name');
$table->index('airway');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('navpoints');
}
}

View File

@@ -0,0 +1,50 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateAcarsTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
/**
* See for defs, modify/update based on this
* https://github.com/skiselkov/openfmc/blob/master/airac.h
*/
Schema::create('acars', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('acars_id', 12);
$table->string('name', 10)->nullable();
$table->float('lat', 7, 4)->default(0.0);
$table->float('lon', 7, 4)->default(0.0);
# TODO: More columns here for what might be required
# polymorphic relation columns.
# parent_type can be flight, pirep or acars
# once
$table->unsignedBigInteger('parent_id');
$table->string('parent_type');
$table->timestamps();
$table->index('created_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('acars');
}
}

View File

@@ -336,7 +336,7 @@ pireps:
dpt_airport_id: KAUS
arr_airport_id: KJFK
flight_time: 180 # 6 hours
status: 0
state: 0
route: PLMMR2 SPA Q22 BEARI FAK PHLBO3
notes: just a pilot report
- id: pirepid_2
@@ -347,7 +347,7 @@ pireps:
dpt_airport_id: KJFK
arr_airport_id: KAUS
flight_time: 180 # 6 hours
status: 0
state: 0
route: PLMMR2 SPA Q22 BEARI FAK PHLBO3
notes: just a pilot report
- id: pirepid_3
@@ -358,7 +358,7 @@ pireps:
dpt_airport_id: KJFK
arr_airport_id: KAUS
flight_time: 180 # 6 hours
status: 0
state: 0
route: PLMMR2 SPA Q22 BEARI FAK PHLBO3
notes: just a pilot report

View File

@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
use App\Http\Requests\CreatePirepRequest;
use App\Http\Requests\UpdatePirepRequest;
use App\Models\Enums\PirepState;
use App\Repositories\AircraftRepository;
use App\Repositories\AirlineRepository;
use App\Repositories\AirportRepository;
@@ -81,7 +82,7 @@ class PirepController extends BaseController
$this->pirepRepo->pushCriteria($criterea);
$pireps = $this->pirepRepo
->findWhere(['status' => config('enums.pirep_status.PENDING')])
->findWhere(['status' => PirepState::PENDING])
->orderBy('created_at', 'desc')
->paginate();
@@ -211,12 +212,12 @@ class PirepController extends BaseController
*/
public function status(Request $request)
{
Log::info('PIREP status update call', [$request->toArray()]);
Log::info('PIREP state update call', [$request->toArray()]);
$pirep = $this->pirepRepo->findWithoutFail($request->id);
if($request->isMethod('post')) {
$new_status = (int) $request->new_status;
$pirep = $this->pirepSvc->changeStatus($pirep, $new_status);
$pirep = $this->pirepSvc->changeState($pirep, $new_status);
}
$pirep->refresh();

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Frontend;
use App\Facades\Utils;
use App\Models\Enums\PirepSource;
use App\Repositories\Criteria\WhereCriteria;
use App\Services\PIREPService;
use Illuminate\Support\Facades\Auth;
@@ -95,7 +96,7 @@ class PirepController extends Controller
$custom_fields[] = [
'name' => $cfield->name,
'value' => $field_val,
'source' => config('enums.sources.MANUAL')
'source' => PirepSource::MANUAL
];
}

10
app/Models/Acars.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Acars extends Model
{
public $table = 'acars';
}

28
app/Models/Enums/Days.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
/**
*
*/
namespace App\Models\Enums;
class Days extends EnumBase {
const MONDAY = 1;
const TUESDAY = 2;
const WEDNESDAY = 4;
const THURSDAY = 8;
const FRIDAY = 16;
const SATURDAY = 32;
const SUNDAY = 64;
protected static $labels = [
Days::MONDAY => 'Monday',
Days::TUESDAY => 'Tuesday',
Days::WEDNESDAY => 'Wednesday',
Days::THURSDAY => 'Thursday',
Days::FRIDAY => 'Friday',
Days::SATURDAY => 'Saturday',
Days::SUNDAY => 'Sunday',
];
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* Created by IntelliJ IDEA.
* User: nshahzad
* Date: 12/19/17
* Time: 8:04 PM
*/
namespace App\Models\Enums;
/**
* Class EnumBase
* @package App\Models\Enums
* TODO: Implement lang translations for enum labels
*/
class EnumBase
{
protected static $labels = [];
/**
* @param $value
* @return mixed
*/
public static function label($value) {
return self::$labels[$value];
}
}

View File

@@ -0,0 +1,22 @@
<?php
/**
* Created by IntelliJ IDEA.
* User: nshahzad
* Date: 12/19/17
* Time: 8:13 PM
*/
namespace App\Models\Enums;
class PirepSource extends EnumBase
{
const MANUAL = 0;
const ACARS = 1;
protected static $labels = [
PirepSource::MANUAL => 'Manual',
PirepSource::ACARS => 'ACARS',
];
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Models\Enums;
use Illuminate\Support\Facades\Facade;
class PirepState extends EnumBase {
const REJECTED = -1;
const PENDING = 0;
const ACCEPTED = 1;
protected static $labels = [
PirepState::REJECTED => 'Rejected',
PirepState::PENDING => 'Pending',
PirepState::ACCEPTED => 'Accepted',
];
}

View File

@@ -0,0 +1,27 @@
<?php
/**
* Enums for PIREP statuses
*/
namespace App\Models\Enums;
/**
* Tied to the ACARS statuses/states
* Class PirepStatus
* @package App\Models\Enums
*/
class PirepStatus extends EnumBase
{
const PREFILE = 0;
const SCHEDULED = 0;
const ENROUTE = 1;
const ARRIVED = 2;
protected static $labels = [
PirepStatus::PREFILE => 'Prefiled',
PirepStatus::SCHEDULED => 'Scheduled',
PirepStatus::ENROUTE => 'Enroute',
PirepStatus::ARRIVED => 'Arrived',
];
}

View File

@@ -59,7 +59,11 @@ class Flight extends Model
'arr_airport_id' => 'required',
];
public function getFlightIdIataAttribute($value)
/**
* Get the flight ident, e.,g JBU1900
* @param $value
*/
public function getIdentAttribute()
{
}

10
app/Models/Navpoint.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Navpoint extends Model
{
public $table = 'navpoints';
}

View File

@@ -37,6 +37,7 @@ class Pirep extends Model
'level',
'route',
'notes',
'state',
'status',
'raw_data',
];
@@ -52,6 +53,7 @@ class Pirep extends Model
'level' => 'integer',
'fuel_used' => 'integer',
'source' => 'integer',
'state' => 'integer',
'status' => 'integer',
];
@@ -60,19 +62,19 @@ class Pirep extends Model
*
* @var array
*/
public static $rules
= [
'dpt_airport_id' => 'required',
'arr_airport_id' => 'required',
];
public static $rules = [
'dpt_airport_id' => 'required',
'arr_airport_id' => 'required',
];
/**
* Get the flight ident, e.,g JBU1900
* @return string
*/
public function getFlightId()
public function getIdentAttribute()
{
$flight_id = $this->airline->code;
if($this->flight_id) {
if ($this->flight_id) {
$flight_id .= $this->flight->flight_number;
} else {
$flight_id .= $this->flight_number;

View File

@@ -5,7 +5,9 @@ namespace App\Providers;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use App\Repositories\SettingRepository;
use Illuminate\Database\Eloquent\Relations\Relation;
use App\Models\Flight;
use App\Models\Pirep;
class AppServiceProvider extends ServiceProvider
{
@@ -16,6 +18,11 @@ class AppServiceProvider extends ServiceProvider
{
Schema::defaultStringLength(191);
Relation::morphMap([
'flights' => Flight::class,
'pireps' => Pirep::class,
]);
$this->app->bind('setting', SettingRepository::class);
//\VaCentral\VaCentral::setVaCentralUrl(config('phpvms.vacentral_api_url'));

View File

@@ -2,6 +2,8 @@
namespace App\Services;
use App\Models\Enums\PirepSource;
use App\Models\Enums\PirepState;
use App\Models\Pirep;
use App\Models\PirepFieldValues;
@@ -46,10 +48,10 @@ class PIREPService extends BaseService
# Figure out what default state should be. Look at the default
# behavior from the rank that the pilot is assigned to
if($pirep->source === config('enums.sources.ACARS')) {
$default_status = $pirep->pilot->rank->auto_approve_acars;
if($pirep->source === PirepSource::ACARS) {
$default_state = $pirep->pilot->rank->auto_approve_acars;
} else {
$default_status = $pirep->pilot->rank->auto_approve_manual;
$default_state = $pirep->pilot->rank->auto_approve_manual;
}
$pirep->save();
@@ -68,12 +70,12 @@ class PIREPService extends BaseService
event(new PirepFiled($pirep));
if ($default_status === config('enums.pirep_status.ACCEPTED')) {
if ($default_state === PirepState::ACCEPTED) {
$pirep = $this->accept($pirep);
}
# only update the pilot last state if they are accepted
if ($default_status === config('enums.pirep_status.ACCEPTED')) {
if ($default_state === PirepState::ACCEPTED) {
$this->setPilotState($pirep);
}
@@ -82,24 +84,24 @@ class PIREPService extends BaseService
/**
* @param Pirep $pirep
* @param int $new_status
* @param int $new_state
* @return Pirep
*/
public function changeStatus(Pirep $pirep, int $new_status): Pirep
public function changeState(Pirep $pirep, int $new_state)
{
Log::info('PIREP ' . $pirep->id . ' status change from '.$pirep->status.' to ' . $new_status);
Log::info('PIREP ' . $pirep->id . ' state change from '.$pirep->state.' to ' . $new_state);
if ($pirep->status === $new_status) {
if ($pirep->state === $new_state) {
return $pirep;
}
/**
* Move from a PENDING status into either ACCEPTED or REJECTED
*/
if ($pirep->status === config('enums.pirep_status.PENDING')) {
if ($new_status === config('enums.pirep_status.ACCEPTED')) {
if ($pirep->state === PirepState::PENDING) {
if ($new_state === PirepState::ACCEPTED) {
return $this->accept($pirep);
} elseif ($new_status === config('enums.pirep_status.REJECTED')) {
} elseif ($new_state === PirepState::REJECTED) {
return $this->reject($pirep);
} else {
return $pirep;
@@ -109,7 +111,7 @@ class PIREPService extends BaseService
/*
* Move from a ACCEPTED to REJECTED status
*/
elseif ($pirep->status === config('enums.pirep_status.ACCEPTED')) {
elseif ($pirep->state === PirepState::ACCEPTED) {
$pirep = $this->reject($pirep);
return $pirep;
}
@@ -117,10 +119,12 @@ class PIREPService extends BaseService
/**
* Move from REJECTED to ACCEPTED
*/
elseif ($pirep->status === config('enums.pirep_status.REJECTED')) {
elseif ($pirep->state === PirepState::REJECTED) {
$pirep = $this->accept($pirep);
return $pirep;
}
return $pirep->refresh();
}
/**
@@ -130,7 +134,7 @@ class PIREPService extends BaseService
public function accept(Pirep $pirep): Pirep
{
# moving from a REJECTED state to ACCEPTED, reconcile statuses
if ($pirep->status === config('enums.pirep_status.ACCEPTED')) {
if ($pirep->state === PirepState::ACCEPTED) {
return $pirep;
}
@@ -143,13 +147,13 @@ class PIREPService extends BaseService
$pirep->pilot->refresh();
# Change the status
$pirep->status = config('enums.pirep_status.ACCEPTED');
$pirep->state = PirepState::ACCEPTED;
$pirep->save();
$pirep->refresh();
$this->setPilotState($pirep);
Log::info('PIREP '.$pirep->id.' status change to ACCEPTED');
Log::info('PIREP '.$pirep->id.' state change to ACCEPTED');
event(new PirepAccepted($pirep));
@@ -164,7 +168,7 @@ class PIREPService extends BaseService
{
# If this was previously ACCEPTED, then reconcile the flight hours
# that have already been counted, etc
if ($pirep->status === config('enums.pirep_status.ACCEPTED')) {
if ($pirep->state === PirepState::ACCEPTED) {
$pilot = $pirep->pilot;
$ft = $pirep->flight_time * -1;
@@ -175,11 +179,11 @@ class PIREPService extends BaseService
}
# Change the status
$pirep->status = config('enums.pirep_status.REJECTED');
$pirep->state = PirepState::REJECTED;
$pirep->save();
$pirep->refresh();
Log::info('PIREP ' . $pirep->id . ' status change to REJECTED');
Log::info('PIREP ' . $pirep->id . ' state change to REJECTED');
event(new PirepRejected($pirep));

View File

@@ -116,5 +116,10 @@ return [
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Yaml' => Symfony\Component\Yaml\Yaml::class,
# ENUMS
'PirepState' => App\Models\Enums\PirepState::class,
'PirepStatus' => App\Models\Enums\PirepStatus::class,
],
];

View File

@@ -17,32 +17,11 @@ return [
'SUSPENDED' => 3,
],
'sources' => [
'MANUAL' => 0,
'ACARS' => 1,
],
'pirep_status' => [
'PENDING' => 0,
'ACCEPTED' => 1,
'REJECTED' => -1,
],
'fuel_types' => [
'100LL' => 0,
'JETA' => 1,
'MOGAS' => 2,
],
'days' => [
'MONDAY' => 1,
'TUESDAY' => 2,
'WEDNESDAY' => 4,
'THURSDAY' => 8,
'FRIDAY' => 16,
'SATURDAY' => 32,
'SUNDAY' => 64
],
];

View File

@@ -7,5 +7,6 @@
<p style="text-align: right">
{!! Form::submit('Go to your site >>', ['class' => 'btn btn-success']) !!}
</p>
{!! PirepState::REJECTED !!}
{!! Form::close() !!}
@endsection

View File

@@ -10,9 +10,9 @@
</a>
</h5>
<div>
@if($pirep->status == config('enums.pirep_status.PENDING'))
@if($pirep->state == PirepState::PENDING)
<div class="badge badge-warning">Pending</div>
@elseif($pirep->status === config('enums.pirep_status.ACCEPTED'))
@elseif($pirep->state === PirepState::ACCEPTED)
<div class="badge badge-success">Accepted</div>
@else
<div class="badge badge-danger">Rejected</div>
@@ -58,13 +58,13 @@
<table class="pull-right">
<tr>
<td>
@if($pirep->status == config('enums.pirep_status.PENDING')
|| $pirep->status == config('enums.pirep_status.REJECTED'))
@if($pirep->state == PirepState::PENDING
|| $pirep->state == PirepState::REJECTED)
{!! Form::open(['url' => '/admin/pireps/'.$pirep->id.'/status', 'method' => 'post',
'name' => 'accept_'.$pirep->id,
'id' => $pirep->id.'_accept',
'pirep_id' => $pirep->id,
'new_status' => config('enums.pirep_status.ACCEPTED'),
'new_status' => PirepState::ACCEPTED,
'class' => 'pirep_submit_status']) !!}
{!! Form::button('Accept', ['type' => 'submit', 'class' => 'btn btn-info']) !!}
{!! Form::close() !!}
@@ -72,13 +72,13 @@
</td>
<td>&nbsp;</td>
<td>
@if($pirep->status == config('enums.pirep_status.PENDING')
|| $pirep->status == config('enums.pirep_status.ACCEPTED'))
@if($pirep->state == PirepState::PENDING
|| $pirep->state == PirepState::ACCEPTED)
{!! Form::open(['url' => '/admin/pireps/'.$pirep->id.'/status', 'method' => 'post',
'name' => 'reject_'.$pirep->id,
'id' => $pirep->id.'_reject',
'pirep_id' => $pirep->id,
'new_status' => config('enums.pirep_status.REJECTED'),
'new_status' => PirepState::REJECTED,
'class' => 'pirep_submit_status']) !!}
{!! Form::button('Reject', ['type' => 'submit', 'class' => 'btn btn-danger']) !!}
{!! Form::close() !!}

View File

@@ -1,5 +1,5 @@
@extends('layouts.default.auth.layout')
@section('title', 'log in')
@section('content')
<div class="col-md-4 content-center">
<div class="card card-login card-plain">

View File

@@ -1,82 +0,0 @@
@extends('layouts.default.app')
@section('content')
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Register</div>
<div class="panel-body">
<form class="form-horizontal" role="form" method="POST" action="{{ url('/register') }}">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label for="name" class="col-md-4 control-label">Name</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control" name="name" value="{{ old('name') }}" required autofocus>
@if ($errors->has('name'))
<span class="help-block">
<strong>{{ $errors->first('name') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required>
@if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control" name="password" required>
@if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
<label for="password-confirm" class="col-md-4 control-label">Confirm Password</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
@if ($errors->has('password_confirmation'))
<span class="help-block">
<strong>{{ $errors->first('password_confirmation') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Register
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@@ -1,5 +1,5 @@
@extends('layouts.default.app')
@section('title', 'register')
@section('content')
<div class="row">
<div class="col-sm-4"></div>

View File

@@ -1,5 +1,6 @@
@extends('layouts.default.app')
@section('title', 'registration submitted')
@section('content')
<div class="container registered-page">
@@ -7,4 +8,4 @@
<p>Your application has been submitted. It requires staff member approval, once a staff member has reviewed your application, you will receive an email confirmation.</p>
</div>
@endsection
@endsection

View File

@@ -1,5 +1,6 @@
@extends('layouts.default.app')
@section('title', 'dashboard')
@section('content')
<div class="row">
<div class="col-sm-8">

View File

@@ -1,5 +1,6 @@
@extends('layouts.default.app')
@section('title', 'flights')
@section('content')
<div class="row">
@include('flash::message')

View File

@@ -1,5 +1,5 @@
@extends('layouts.default.app')
@section('title', 'file pirep')
@section('content')
<div class="row">
<div class="col-md-12">

View File

@@ -1,5 +1,5 @@
@extends('layouts.default.app')
@section('title', 'pireps')
@section('content')
<div class="row">
<div class="col-md-12">

View File

@@ -1,6 +1,6 @@
@extends('layouts.default.app')
@section('title', 'PIREP '.$pirep->getFlightId())
@section('title', 'PIREP '.$pirep->ident)
@section('content')
<div class="row">
<div class="col-md-12">
@@ -14,9 +14,9 @@
<tr>
<td>Status</td>
<td>
@if($pirep->status == config('enums.pirep_status.PENDING'))
@if($pirep->state == PirepState::PENDING)
<div class="badge badge-warning ">Pending</div>
@elseif($pirep->status === config('enums.pirep_status.ACCEPTED'))
@elseif($pirep->state === PirepState::ACCEPTED)
<div class="badge badge-success">Accepted</div>
@else
<div class="badge badge-danger">Rejected</div>

View File

@@ -14,9 +14,9 @@
</a>
</h5>
<div>
@if($pirep->status == config('enums.pirep_status.PENDING'))
@if($pirep->state == PirepState::PENDING)
<div class="badge badge-warning">Pending</div>
@elseif($pirep->status == config('enums.pirep_status.ACCEPTED'))
@elseif($pirep->state == PirepState::ACCEPTED)
<div class="badge badge-success">Accepted</div>
@else
<div class="badge badge-danger">Rejected</div>

View File

@@ -1,5 +1,5 @@
@extends('layouts.default.app')
@section('title', 'profile')
@section('content')
<div class="container profile-page">
<div class="page-header page-header-small text-color-dark-beige">

View File

@@ -1,5 +1,6 @@
<?php
use App\Models\Enums\PirepState;
use App\Models\User;
use App\Models\Pirep;
@@ -9,7 +10,6 @@ use Illuminate\Foundation\Testing\WithoutMiddleware;
class PIREPTest extends TestCase
{
use WithoutMiddleware;
#use DatabaseMigrations;
protected $pirepSvc;
@@ -28,9 +28,9 @@ class PIREPTest extends TestCase
$pirep = $this->pirepSvc->create($pirep, []);
/**
* Check the initial status info
* Check the initial state info
*/
$this->assertEquals($pirep->status, config('enums.pirep_status.PENDING'));
$this->assertEquals($pirep->state, PirepState::PENDING);
/**
* Now set the PIREP state to ACCEPTED
@@ -39,7 +39,7 @@ class PIREPTest extends TestCase
$original_flight_time = $pirep->pilot->flight_time ;
$new_flight_time = $pirep->pilot->flight_time + $pirep->flight_time;
$this->pirepSvc->changeStatus($pirep, '1');
$this->pirepSvc->changeState($pirep, PirepState::ACCEPTED);
$this->assertEquals($new_pirep_count, $pirep->pilot->flights);
$this->assertEquals($new_flight_time, $pirep->pilot->flight_time);
$this->assertEquals($pirep->arr_airport_id, $pirep->pilot->curr_airport_id);
@@ -50,10 +50,9 @@ class PIREPTest extends TestCase
*/
$new_pirep_count = $pirep->pilot->flights - 1;
$new_flight_time = $pirep->pilot->flight_time - $pirep->flight_time;
$this->pirepSvc->changeStatus($pirep, config('enums.pirep_status.REJECTED'));
$this->pirepSvc->changeState($pirep, PirepState::REJECTED);
$this->assertEquals($new_pirep_count, $pirep->pilot->flights);
$this->assertEquals($new_flight_time, $pirep->pilot->flight_time);
//$this->assertEquals(1, $pirep->pilot->rank_id);
$this->assertEquals($pirep->arr_airport_id, $pirep->pilot->curr_airport_id);
}
@@ -101,7 +100,7 @@ class PIREPTest extends TestCase
$latest_pirep = Pirep::where('id', $pilot->last_pirep_id)->first();
# Make sure PIREP was auto updated
$this->assertEquals(config('enums.pirep_status.ACCEPTED'), $latest_pirep->status);
$this->assertEquals(PirepState::ACCEPTED, $latest_pirep->state);
# Make sure latest PIREP was updated
$this->assertNotEquals($last_pirep->id, $latest_pirep->id);