Apply fixes from StyleCI

This commit is contained in:
Nabeel Shahzad
2018-08-26 16:40:04 +00:00
committed by StyleCI Bot
parent 20f46adbc4
commit 9596d88b48
407 changed files with 4032 additions and 3286 deletions

View File

@@ -11,18 +11,19 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
/**
* Class Acars
*
* @param string id
*
* @property string pirep_id
* @property int type
* @property string name
* @property double lat
* @property double lon
* @property double altitude
* @property float lat
* @property float lon
* @property float altitude
* @property int gs
* @property int heading
* @property int order
* @property int nav_type
* @package App\Models
*/
class Acars extends Model
{
@@ -78,15 +79,15 @@ class Acars extends Model
'pirep_id' => 'required',
];
/**
* Return a new Length unit so conversions can be made
*
* @return int|Distance
*/
public function getDistanceAttribute()
{
if (!array_key_exists('distance', $this->attributes)) {
return null;
return;
}
try {
@@ -105,6 +106,7 @@ class Acars extends Model
/**
* Set the distance unit, convert to our internal default unit
*
* @param $value
*/
public function setDistanceAttribute($value): void
@@ -119,12 +121,13 @@ class Acars extends Model
/**
* Return a new Fuel unit so conversions can be made
*
* @return int|Fuel
*/
public function getFuelAttribute()
{
if (!array_key_exists('fuel', $this->attributes)) {
return null;
return;
}
try {
@@ -139,6 +142,7 @@ class Acars extends Model
/**
* Set the amount of fuel
*
* @param $value
*/
public function setFuelAttribute($value)
@@ -155,7 +159,6 @@ class Acars extends Model
/**
* FKs
*/
public function pirep()
{
return $this->belongsTo(Pirep::class, 'pirep_id');

View File

@@ -18,7 +18,6 @@ use App\Models\Traits\FilesTrait;
* @property Subfleet subfleet
* @property int status
* @property int state
* @package App\Models
*/
class Aircraft extends Model
{
@@ -60,6 +59,7 @@ class Aircraft extends Model
/**
* See if this aircraft is active
*
* @return bool
*/
public function getActiveAttribute(): bool
@@ -69,6 +69,7 @@ class Aircraft extends Model
/**
* Capitalize the ICAO when set
*
* @param $icao
*/
public function setIcaoAttribute($icao): void
@@ -79,7 +80,6 @@ class Aircraft extends Model
/**
* foreign keys
*/
public function airport()
{
return $this->belongsTo(Airport::class, 'airport_id');

View File

@@ -9,6 +9,7 @@ use App\Models\Traits\JournalTrait;
/**
* Class Airline
*
* @property mixed id
* @property string code
* @property string icao
@@ -17,7 +18,6 @@ use App\Models\Traits\JournalTrait;
* @property string logo
* @property string country
* @property Journal journal
* @package App\Models
*/
class Airline extends Model
{
@@ -44,6 +44,7 @@ class Airline extends Model
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts = [
@@ -54,6 +55,7 @@ class Airline extends Model
/**
* Validation rules
*
* @var array
*/
public static $rules = [
@@ -69,14 +71,15 @@ class Airline extends Model
*/
public function getCodeAttribute()
{
if ($this->iata && $this->iata !== '')
return $this->iata;
else
return $this->icao;
if ($this->iata && $this->iata !== '') {
return $this->iata;
}
return $this->icao;
}
/**
* Capitalize the IATA code when set
*
* @param $iata
*/
public function setIataAttribute($iata)
@@ -86,6 +89,7 @@ class Airline extends Model
/**
* Capitalize the ICAO when set
*
* @param $icao
*/
public function setIcaoAttribute($icao): void

View File

@@ -8,6 +8,7 @@ use App\Models\Traits\FilesTrait;
/**
* Class Airport
*
* @property string id
* @property string iata
* @property string icao
@@ -18,7 +19,6 @@ use App\Models\Traits\FilesTrait;
* @property float ground_handling_cost
* @property float lat
* @property float lon
* @package App\Models
*/
class Airport extends Model
{
@@ -91,6 +91,7 @@ class Airport extends Model
/**
* Return full name like:
* KJFK - John F Kennedy
*
* @return string
*/
public function getFullNameAttribute(): string
@@ -100,6 +101,7 @@ class Airport extends Model
/**
* Shorthand for getting the timezone
*
* @return string
*/
public function getTzAttribute(): string
@@ -109,6 +111,7 @@ class Airport extends Model
/**
* Shorthand for setting the timezone
*
* @param $value
*/
public function setTzAttribute($value): void

View File

@@ -6,10 +6,10 @@ use App\Interfaces\Model;
/**
* The Award model
*
* @property mixed id
* @property mixed ref_model
* @property mixed|null ref_model_params
* @package Award\Models
*/
class Award extends Model
{
@@ -28,25 +28,27 @@ class Award extends Model
'description' => 'nullable',
'image_url' => 'nullable',
'ref_model' => 'required',
'ref_model_params' => 'nullable'
'ref_model_params' => 'nullable',
];
/**
* Get the referring object
*
* @param Award|null $award
* @param User|null $user
*
* @return null
*/
public function getReference(Award $award = null, User $user = null)
public function getReference(self $award = null, User $user = null)
{
if (!$this->ref_model) {
return null;
return;
}
try {
return new $this->ref_model($award, $user);
} catch (\Exception $e) {
return null;
return;
}
}
}

View File

@@ -4,9 +4,6 @@ namespace App\Models;
use App\Interfaces\Model;
/**
* @package App\Models
*/
class Bid extends Model
{
public $table = 'bids';

View File

@@ -6,11 +6,10 @@ use App\Interfaces\Enum;
/**
* Class AcarsType
* @package App\Models\Enums
*/
class AcarsType extends Enum
{
public const FLIGHT_PATH = 0;
public const ROUTE = 1;
public const LOG = 2;
public const ROUTE = 1;
public const LOG = 2;
}

View File

@@ -6,15 +6,14 @@ use App\Interfaces\Enum;
/**
* Class ActiveState
* @package App\Models\Enums
*/
class ActiveState extends Enum
{
public const INACTIVE = 0;
public const ACTIVE = 1;
public const ACTIVE = 1;
public static $labels = [
ActiveState::ACTIVE => 'common.active',
ActiveState::INACTIVE => 'common.inactive',
self::ACTIVE => 'common.active',
self::INACTIVE => 'common.inactive',
];
}

View File

@@ -6,7 +6,6 @@ use App\Interfaces\Enum;
/**
* Class AircraftState
* @package App\Models\Enums
*/
class AircraftState extends Enum
{
@@ -15,8 +14,8 @@ class AircraftState extends Enum
public const IN_AIR = 2;
public static $labels = [
AircraftState::PARKED => 'On Ground',
AircraftState::IN_USE => 'In Use',
AircraftState::IN_AIR => 'In Air',
self::PARKED => 'On Ground',
self::IN_USE => 'In Use',
self::IN_AIR => 'In Air',
];
}

View File

@@ -6,21 +6,20 @@ use App\Interfaces\Enum;
/**
* Class AircraftState
* @package App\Models\Enums
*/
class AircraftStatus extends Enum
{
public const ACTIVE = 'A';
public const STORED = 'S';
public const RETIRED = 'R';
public const SCRAPPED = 'C';
public const ACTIVE = 'A';
public const STORED = 'S';
public const RETIRED = 'R';
public const SCRAPPED = 'C';
public const WRITTEN_OFF = 'W';
public static $labels = [
AircraftStatus::ACTIVE => 'aircraft.status.active',
AircraftStatus::STORED => 'aircraft.status.stored',
AircraftStatus::RETIRED => 'aircraft.status.retired',
AircraftStatus::SCRAPPED => 'aircraft.status.scrapped',
AircraftStatus::WRITTEN_OFF => 'aircraft.status.written',
self::ACTIVE => 'aircraft.status.active',
self::STORED => 'aircraft.status.stored',
self::RETIRED => 'aircraft.status.retired',
self::SCRAPPED => 'aircraft.status.scrapped',
self::WRITTEN_OFF => 'aircraft.status.written',
];
}

View File

@@ -6,11 +6,10 @@ use App\Interfaces\Enum;
/**
* Class AnalyticsDimensions
* @package App\Models\Enums
*/
class AnalyticsDimensions extends Enum
{
public const PHP_VERSION = 1;
public const PHP_VERSION = 1;
public const DATABASE_VERSION = 2;
public const PHPVMS_VERSION = 3;
public const PHPVMS_VERSION = 3;
}

View File

@@ -7,10 +7,9 @@ use App\Interfaces\Enum;
/**
* Class AnalyticsMetrics
* Metrics IDs used in Google Analytics
* @package App\Models\Enums
*/
class AnalyticsMetrics extends Enum
{
# Track the lookup time for airports from vaCentral
// Track the lookup time for airports from vaCentral
public const AIRPORT_LOOKUP_TIME = 1;
}

View File

@@ -7,60 +7,61 @@ use App\Interfaces\Enum;
/**
* Class Days
* Start on Monday - ISO8601
* @package App\Models\Enums
*/
class Days extends Enum
{
public const MONDAY = 1 << 0;
public const TUESDAY = 1 << 1;
public const MONDAY = 1 << 0;
public const TUESDAY = 1 << 1;
public const WEDNESDAY = 1 << 2;
public const THURSDAY = 1 << 3;
public const FRIDAY = 1 << 4;
public const SATURDAY = 1 << 5;
public const SUNDAY = 1 << 6;
public const THURSDAY = 1 << 3;
public const FRIDAY = 1 << 4;
public const SATURDAY = 1 << 5;
public const SUNDAY = 1 << 6;
public static $labels = [
Days::MONDAY => 'common.days.mon',
Days::TUESDAY => 'common.days.tues',
Days::WEDNESDAY => 'common.days.wed',
Days::THURSDAY => 'common.days.thurs',
Days::FRIDAY => 'common.days.fri',
Days::SATURDAY => 'common.days.sat',
Days::SUNDAY => 'common.days.sun',
self::MONDAY => 'common.days.mon',
self::TUESDAY => 'common.days.tues',
self::WEDNESDAY => 'common.days.wed',
self::THURSDAY => 'common.days.thurs',
self::FRIDAY => 'common.days.fri',
self::SATURDAY => 'common.days.sat',
self::SUNDAY => 'common.days.sun',
];
public static $codes = [
'M' => Days::MONDAY,
'T' => Days::TUESDAY,
'W' => Days::WEDNESDAY,
'Th' => Days::THURSDAY,
'F' => Days::FRIDAY,
'S' => Days::SATURDAY,
'Su' => Days::SUNDAY,
'M' => self::MONDAY,
'T' => self::TUESDAY,
'W' => self::WEDNESDAY,
'Th' => self::THURSDAY,
'F' => self::FRIDAY,
'S' => self::SATURDAY,
'Su' => self::SUNDAY,
];
/**
* Map the ISO8601 numeric today to day
*/
public static $isoDayMap = [
1 => Days::MONDAY,
2 => Days::TUESDAY,
3 => Days::WEDNESDAY,
4 => Days::THURSDAY,
5 => Days::FRIDAY,
6 => Days::SATURDAY,
7 => Days::SUNDAY,
1 => self::MONDAY,
2 => self::TUESDAY,
3 => self::WEDNESDAY,
4 => self::THURSDAY,
5 => self::FRIDAY,
6 => self::SATURDAY,
7 => self::SUNDAY,
];
/**
* Create the masked value for the days of week
*
* @param array $days
*
* @return int|mixed
*/
public static function getDaysMask(array $days)
{
$mask = 0;
foreach($days as $day) {
foreach ($days as $day) {
$mask |= $day;
}
@@ -69,8 +70,10 @@ class Days extends Enum
/**
* See if the given mask has a day
*
* @param $mask
* @param $day
*
* @return bool
*/
public static function in($mask, $day): bool
@@ -80,7 +83,9 @@ class Days extends Enum
/**
* Does the mask contain today?
*
* @param $val
*
* @return bool
*/
public static function isToday($val): bool

View File

@@ -6,23 +6,22 @@ use App\Interfaces\Enum;
/**
* Class ExpenseType
* @package App\Models\Enums
*/
class ExpenseType extends Enum
{
public const FLIGHT = 'F';
public const DAILY = 'D';
public const FLIGHT = 'F';
public const DAILY = 'D';
public const MONTHLY = 'M';
protected static $labels = [
ExpenseType::FLIGHT => 'expenses.type.flight',
ExpenseType::DAILY => 'expenses.type.daily',
ExpenseType::MONTHLY => 'expenses.type.monthly',
self::FLIGHT => 'expenses.type.flight',
self::DAILY => 'expenses.type.daily',
self::MONTHLY => 'expenses.type.monthly',
];
protected static $codes = [
ExpenseType::FLIGHT => 'F',
ExpenseType::DAILY =>'D',
ExpenseType::MONTHLY => 'M',
self::FLIGHT => 'F',
self::DAILY => 'D',
self::MONTHLY => 'M',
];
}

View File

@@ -6,41 +6,40 @@ use App\Interfaces\Enum;
/**
* Class FlightType
* @package App\Models\Enums
*/
class FlightType extends Enum
{
public const SCHED_PAX = 'J';
public const SCHED_CARGO = 'F';
public const CHARTER_PAX_ONLY = 'C';
public const ADDITIONAL_CARGO = 'A';
public const VIP = 'E';
public const ADDTL_PAX = 'G';
public const SCHED_PAX = 'J';
public const SCHED_CARGO = 'F';
public const CHARTER_PAX_ONLY = 'C';
public const ADDITIONAL_CARGO = 'A';
public const VIP = 'E';
public const ADDTL_PAX = 'G';
public const CHARTER_CARGO_MAIL = 'H';
public const AMBULANCE = 'I';
public const TRAINING = 'K';
public const MAIL_SERVICE = 'M';
public const CHARTER_SPECIAL = 'O';
public const POSITIONING = 'P';
public const TECHNICAL_TEST = 'T';
public const MILITARY = 'W';
public const TECHNICAL_STOP = 'X';
public const AMBULANCE = 'I';
public const TRAINING = 'K';
public const MAIL_SERVICE = 'M';
public const CHARTER_SPECIAL = 'O';
public const POSITIONING = 'P';
public const TECHNICAL_TEST = 'T';
public const MILITARY = 'W';
public const TECHNICAL_STOP = 'X';
protected static $labels = [
FlightType::SCHED_PAX => 'flights.type.pass_scheduled',
FlightType::SCHED_CARGO => 'flights.type.cargo_scheduled',
FlightType::CHARTER_PAX_ONLY => 'flights.type.charter_pass_only',
FlightType::ADDITIONAL_CARGO => 'flights.type.addtl_cargo_mail',
FlightType::VIP => 'flights.type.special_vip',
FlightType::ADDTL_PAX => 'flights.type.pass_addtl',
FlightType::CHARTER_CARGO_MAIL => 'flights.type.charter_cargo',
FlightType::AMBULANCE => 'flights.type.ambulance',
FlightType::TRAINING => 'flights.type.training_flight',
FlightType::MAIL_SERVICE => 'flights.type.mail_service',
FlightType::CHARTER_SPECIAL => 'flights.type.charter_special',
FlightType::POSITIONING => 'flights.type.positioning',
FlightType::TECHNICAL_TEST => 'flights.type.technical_test',
FlightType::MILITARY => 'flights.type.military',
FlightType::TECHNICAL_STOP => 'flights.type.technical_stop',
self::SCHED_PAX => 'flights.type.pass_scheduled',
self::SCHED_CARGO => 'flights.type.cargo_scheduled',
self::CHARTER_PAX_ONLY => 'flights.type.charter_pass_only',
self::ADDITIONAL_CARGO => 'flights.type.addtl_cargo_mail',
self::VIP => 'flights.type.special_vip',
self::ADDTL_PAX => 'flights.type.pass_addtl',
self::CHARTER_CARGO_MAIL => 'flights.type.charter_cargo',
self::AMBULANCE => 'flights.type.ambulance',
self::TRAINING => 'flights.type.training_flight',
self::MAIL_SERVICE => 'flights.type.mail_service',
self::CHARTER_SPECIAL => 'flights.type.charter_special',
self::POSITIONING => 'flights.type.positioning',
self::TECHNICAL_TEST => 'flights.type.technical_test',
self::MILITARY => 'flights.type.military',
self::TECHNICAL_STOP => 'flights.type.technical_stop',
];
}

View File

@@ -6,17 +6,16 @@ use App\Interfaces\Enum;
/**
* Class FuelType
* @package App\Models\Enums
*/
class FuelType extends Enum
{
public const LOW_LEAD = 0;
public const JET_A = 1;
public const MOGAS = 2;
public const JET_A = 1;
public const MOGAS = 2;
public static $labels = [
FuelType::LOW_LEAD => '100LL',
FuelType::JET_A => 'JET A',
FuelType::MOGAS => 'MOGAS',
self::LOW_LEAD => '100LL',
self::JET_A => 'JET A',
self::MOGAS => 'MOGAS',
];
}

View File

@@ -6,10 +6,9 @@ use App\Interfaces\Enum;
/**
* Class JournalType
* @package App\Models\Enums
*/
class JournalType extends Enum
{
public const AIRLINE = 0;
public const USER = 1;
public const USER = 1;
}

View File

@@ -8,49 +8,49 @@ use App\Interfaces\Enum;
* Class NavaidType
* Types based on/compatible with OpenFMC
* https://github.com/skiselkov/openfmc/blob/master/airac.h
* @package App\Models\Enums
*/
class NavaidType extends Enum
{
public const VOR = 1 << 0;
public const VOR_DME = 1 << 1;
public const LOC = 1 << 4;
public const LOC_DME = 1 << 5;
public const NDB = 1 << 6;
public const TACAN = 1 << 7;
public const UNKNOWN = 1 << 8;
public const VOR = 1 << 0;
public const VOR_DME = 1 << 1;
public const LOC = 1 << 4;
public const LOC_DME = 1 << 5;
public const NDB = 1 << 6;
public const TACAN = 1 << 7;
public const UNKNOWN = 1 << 8;
public const INNER_MARKER = 1 << 9;
public const OUTER_MARKER = 1 << 10;
public const FIX = 1 << 11;
public const ANY_VOR = NavaidType::VOR | NavaidType::VOR_DME;
public const ANY_LOC = NavaidType::LOC | NavaidType::LOC_DME;
public const ANY = (NavaidType::UNKNOWN << 1) - 1;
public const FIX = 1 << 11;
public const ANY_VOR = self::VOR | self::VOR_DME;
public const ANY_LOC = self::LOC | self::LOC_DME;
public const ANY = (self::UNKNOWN << 1) - 1;
/**
* Names and titles
*
* @var array
*/
public static $labels = [
NavaidType::VOR => 'VOR',
NavaidType::VOR_DME => 'VOR DME',
NavaidType::LOC => 'Localizer',
NavaidType::LOC_DME => 'Localizer DME',
NavaidType::NDB => 'Non-directional Beacon',
NavaidType::TACAN => 'TACAN',
NavaidType::UNKNOWN => 'Unknown',
NavaidType::ANY_VOR => 'VOR',
NavaidType::ANY_LOC => 'Localizer',
self::VOR => 'VOR',
self::VOR_DME => 'VOR DME',
self::LOC => 'Localizer',
self::LOC_DME => 'Localizer DME',
self::NDB => 'Non-directional Beacon',
self::TACAN => 'TACAN',
self::UNKNOWN => 'Unknown',
self::ANY_VOR => 'VOR',
self::ANY_LOC => 'Localizer',
];
public static $icons = [
NavaidType::VOR => 'VOR',
NavaidType::VOR_DME => 'VOR DME',
NavaidType::LOC => 'Localizer',
NavaidType::LOC_DME => 'Localizer DME',
NavaidType::NDB => 'Non-directional Beacon',
NavaidType::TACAN => 'TACAN',
NavaidType::UNKNOWN => 'Unknown',
NavaidType::ANY_VOR => 'VOR',
NavaidType::ANY_LOC => 'Localizer',
self::VOR => 'VOR',
self::VOR_DME => 'VOR DME',
self::LOC => 'Localizer',
self::LOC_DME => 'Localizer DME',
self::NDB => 'Non-directional Beacon',
self::TACAN => 'TACAN',
self::UNKNOWN => 'Unknown',
self::ANY_VOR => 'VOR',
self::ANY_LOC => 'Localizer',
];
}

View File

@@ -6,10 +6,9 @@ use App\Interfaces\Enum;
/**
* Class AcarsType
* @package App\Models\Enums
*/
class PirepFieldSource extends Enum
{
public const MANUAL = 0;
public const ACARS = 1;
public const ACARS = 1;
}

View File

@@ -6,15 +6,14 @@ use App\Interfaces\Enum;
/**
* Class PirepSource
* @package App\Models\Enums
*/
class PirepSource extends Enum
{
public const MANUAL = 0;
public const ACARS = 1;
public const ACARS = 1;
protected static $labels = [
PirepSource::MANUAL => 'pireps.source_types.manual',
PirepSource::ACARS => 'pireps.source_types.acars',
self::MANUAL => 'pireps.source_types.manual',
self::ACARS => 'pireps.source_types.acars',
];
}

View File

@@ -6,25 +6,24 @@ use App\Interfaces\Enum;
/**
* Class PirepState
* @package App\Models\Enums
*/
class PirepState extends Enum
{
public const REJECTED = -1;
public const REJECTED = -1;
public const IN_PROGRESS = 0; // flight is ongoing
public const PENDING = 1; // waiting admin approval
public const ACCEPTED = 2;
public const CANCELLED = 3;
public const DELETED = 4;
public const DRAFT = 5;
public const PENDING = 1; // waiting admin approval
public const ACCEPTED = 2;
public const CANCELLED = 3;
public const DELETED = 4;
public const DRAFT = 5;
protected static $labels = [
PirepState::REJECTED => 'pireps.state.rejected',
PirepState::IN_PROGRESS => 'pireps.state.in_progress',
PirepState::PENDING => 'pireps.state.pending',
PirepState::ACCEPTED => 'pireps.state.accepted',
PirepState::CANCELLED => 'pireps.state.cancelled',
PirepState::DELETED => 'pireps.state.deleted',
PirepState::DRAFT => 'pireps.state.draft',
self::REJECTED => 'pireps.state.rejected',
self::IN_PROGRESS => 'pireps.state.in_progress',
self::PENDING => 'pireps.state.pending',
self::ACCEPTED => 'pireps.state.accepted',
self::CANCELLED => 'pireps.state.cancelled',
self::DELETED => 'pireps.state.deleted',
self::DRAFT => 'pireps.state.draft',
];
}

View File

@@ -8,57 +8,56 @@ use App\Interfaces\Enum;
* Tied to the ACARS statuses/states.
* Corresponds to values from AIDX and ICAO ADREP
* https://www.skybrary.aero/index.php/Flight_Phase_Taxonomy
* @package App\Models\Enums
*/
class PirepStatus extends Enum
{
public const INITIATED = 'INI';
public const SCHEDULED = 'SCH';
public const BOARDING = 'BST';
public const RDY_START = 'RDT';
public const PUSHBACK_TOW = 'PBT';
public const DEPARTED = 'OFB'; // Off block
public const RDY_DEICE = 'DIR';
public const STRT_DEICE = 'DIC';
public const GRND_RTRN = 'GRT'; // Ground return
public const TAXI = 'TXI'; // Taxi
public const TAKEOFF = 'TOF';
public const INIT_CLIM = 'ICL';
public const AIRBORNE = 'TKO';
public const ENROUTE = 'ENR';
public const DIVERTED = 'DV';
public const APPROACH = 'TEN';
public const INITIATED = 'INI';
public const SCHEDULED = 'SCH';
public const BOARDING = 'BST';
public const RDY_START = 'RDT';
public const PUSHBACK_TOW = 'PBT';
public const DEPARTED = 'OFB'; // Off block
public const RDY_DEICE = 'DIR';
public const STRT_DEICE = 'DIC';
public const GRND_RTRN = 'GRT'; // Ground return
public const TAXI = 'TXI'; // Taxi
public const TAKEOFF = 'TOF';
public const INIT_CLIM = 'ICL';
public const AIRBORNE = 'TKO';
public const ENROUTE = 'ENR';
public const DIVERTED = 'DV';
public const APPROACH = 'TEN';
public const APPROACH_ICAO = 'APR';
public const ON_FINAL = 'FIN';
public const LANDING = 'LDG';
public const LANDED = 'LAN';
public const ARRIVED = 'ONB'; // On block
public const CANCELLED = 'DX';
public const EMERG_DECENT = 'EMG';
public const ON_FINAL = 'FIN';
public const LANDING = 'LDG';
public const LANDED = 'LAN';
public const ARRIVED = 'ONB'; // On block
public const CANCELLED = 'DX';
public const EMERG_DECENT = 'EMG';
protected static $labels = [
PirepStatus::INITIATED => 'pireps.status.initialized',
PirepStatus::SCHEDULED => 'pireps.status.scheduled',
PirepStatus::BOARDING => 'pireps.status.boarding',
PirepStatus::RDY_START => 'pireps.status.ready_start',
PirepStatus::PUSHBACK_TOW => 'pireps.status.push_tow',
PirepStatus::DEPARTED => 'pireps.status.departed',
PirepStatus::RDY_DEICE => 'pireps.status.ready_deice',
PirepStatus::STRT_DEICE => 'pireps.status.deicing',
PirepStatus::GRND_RTRN => 'pireps.status.ground_ret',
PirepStatus::TAXI => 'pireps.status.taxi',
PirepStatus::TAKEOFF => 'pireps.status.takeoff',
PirepStatus::INIT_CLIM => 'pireps.status.initial_clb',
PirepStatus::AIRBORNE => 'pireps.status.enroute',
PirepStatus::ENROUTE => 'pireps.status.enroute',
PirepStatus::DIVERTED => 'pireps.status.diverted',
PirepStatus::APPROACH => 'pireps.status.approach',
PirepStatus::APPROACH_ICAO => 'pireps.status.approach',
PirepStatus::ON_FINAL => 'pireps.status.final_appr',
PirepStatus::LANDING => 'pireps.status.landing',
PirepStatus::LANDED => 'pireps.status.landed',
PirepStatus::ARRIVED => 'pireps.status.arrived',
PirepStatus::CANCELLED => 'pireps.status.cancelled',
PirepStatus::EMERG_DECENT => 'pireps.status.emerg_decent',
self::INITIATED => 'pireps.status.initialized',
self::SCHEDULED => 'pireps.status.scheduled',
self::BOARDING => 'pireps.status.boarding',
self::RDY_START => 'pireps.status.ready_start',
self::PUSHBACK_TOW => 'pireps.status.push_tow',
self::DEPARTED => 'pireps.status.departed',
self::RDY_DEICE => 'pireps.status.ready_deice',
self::STRT_DEICE => 'pireps.status.deicing',
self::GRND_RTRN => 'pireps.status.ground_ret',
self::TAXI => 'pireps.status.taxi',
self::TAKEOFF => 'pireps.status.takeoff',
self::INIT_CLIM => 'pireps.status.initial_clb',
self::AIRBORNE => 'pireps.status.enroute',
self::ENROUTE => 'pireps.status.enroute',
self::DIVERTED => 'pireps.status.diverted',
self::APPROACH => 'pireps.status.approach',
self::APPROACH_ICAO => 'pireps.status.approach',
self::ON_FINAL => 'pireps.status.final_appr',
self::LANDING => 'pireps.status.landing',
self::LANDED => 'pireps.status.landed',
self::ARRIVED => 'pireps.status.arrived',
self::CANCELLED => 'pireps.status.cancelled',
self::EMERG_DECENT => 'pireps.status.emerg_decent',
];
}

View File

@@ -6,21 +6,20 @@ use App\Interfaces\Enum;
/**
* Class UserState
* @package App\Models\Enums
*/
class UserState extends Enum
{
public const PENDING = 0;
public const ACTIVE = 1;
public const REJECTED = 2;
public const ON_LEAVE = 3;
public const PENDING = 0;
public const ACTIVE = 1;
public const REJECTED = 2;
public const ON_LEAVE = 3;
public const SUSPENDED = 4;
protected static $labels = [
UserState::PENDING => 'user.state.pending',
UserState::ACTIVE => 'user.state.active',
UserState::REJECTED => 'user.state.rejected',
UserState::ON_LEAVE => 'user.state.on_leave',
UserState::SUSPENDED => 'user.state.suspended',
self::PENDING => 'user.state.pending',
self::ACTIVE => 'user.state.active',
self::REJECTED => 'user.state.rejected',
self::ON_LEAVE => 'user.state.on_leave',
self::SUSPENDED => 'user.state.suspended',
];
}

View File

@@ -1,17 +1,18 @@
<?php
namespace App\Models;
use App\Interfaces\Model;
use App\Models\Traits\ReferenceTrait;
/**
* Class Expense
*
* @property int airline_id
* @property float amount
* @property string name
* @property string ref_model
* @property string ref_model_id
* @package App\Models
*/
class Expense extends Model
{
@@ -42,7 +43,6 @@ class Expense extends Model
/**
* Foreign Keys
*/
public function airline()
{
return $this->belongsTo(Airline::class, 'airline_id');

View File

@@ -1,16 +1,17 @@
<?php
namespace App\Models;
use App\Interfaces\Model;
/**
* Class Fare
* @property integer capacity
*
* @property int capacity
* @property float cost
* @property float price
* @property mixed code
* @property mixed count Only when merged with pivot
* @package App\Models
*/
class Fare extends Model
{
@@ -41,7 +42,6 @@ class Fare extends Model
/**
* any foreign keys
*/
public function subfleets()
{
return $this->belongsToMany(Subfleet::class, 'subfleet_fare')

View File

@@ -2,7 +2,6 @@
namespace App\Models;
use App\Interfaces\Model;
use App\Models\Traits\HashIdTrait;
use App\Models\Traits\ReferenceTrait;
@@ -13,11 +12,10 @@ use Illuminate\Support\Facades\Storage;
* @property string $description
* @property string $disk
* @property string $path
* @property boolean $public
* @property bool $public
* @property int $download_count
* @property string $url
* @property string $filename
* @package App\Models
*/
class File extends Model
{
@@ -42,13 +40,14 @@ class File extends Model
];
public static $rules = [
'name' => 'required',
'name' => 'required',
];
private $pathinfo;
/**
* Return the file extension
*
* @return string
*/
public function getExtensionAttribute(): string
@@ -62,6 +61,7 @@ class File extends Model
/**
* Get just the filename
*
* @return string
*/
public function getFilenameAttribute() :string
@@ -75,6 +75,7 @@ class File extends Model
/**
* Get the full URL to this attribute
*
* @return string
*/
public function getUrlAttribute(): string

View File

@@ -15,7 +15,7 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
* @property string id
* @property mixed ident
* @property Airline airline
* @property integer airline_id
* @property int airline_id
* @property mixed flight_number
* @property mixed route_code
* @property int route_leg
@@ -23,7 +23,7 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
* @property Collection field_values
* @property Collection fares
* @property Collection subfleets
* @property integer days
* @property int days
* @property Airport dep_airport
* @property Airport arr_airport
* @property Airport alt_airport
@@ -42,7 +42,8 @@ class Flight extends Model
public $incrementing = false;
/** The form wants this */
public $hours, $minutes;
public $hours;
public $minutes;
protected $fillable = [
'id',
@@ -96,13 +97,15 @@ class Flight extends Model
/**
* Return all of the flights on any given day(s) of the week
* Search using bitmasks
*
* @param Days[] $days List of the enumerated values
*
* @return Flight
*/
public static function findByDays(array $days)
{
$flights = Flight::where('active', true);
foreach($days as $day) {
$flights = self::where('active', true);
foreach ($days as $day) {
$flights = $flights->where('days', '&', $day);
}
@@ -130,12 +133,13 @@ class Flight extends Model
/**
* Return a new Length unit so conversions can be made
*
* @return int|Distance
*/
public function getDistanceAttribute()
{
if (!array_key_exists('distance', $this->attributes)) {
return null;
return;
}
try {
@@ -151,6 +155,7 @@ class Flight extends Model
/**
* Set the distance unit, convert to our internal default unit
*
* @param $value
*/
public function setDistanceAttribute($value): void
@@ -166,6 +171,7 @@ class Flight extends Model
/**
* @param $day
*
* @return bool
*/
public function on_day($day): bool
@@ -175,13 +181,15 @@ class Flight extends Model
/**
* Return a custom field value
*
* @param $field_name
*
* @return string
*/
public function field($field_name): string
{
$field = $this->field_values->where('name', $field_name)->first();
if($field) {
if ($field) {
return $field['value'];
}
@@ -191,6 +199,7 @@ class Flight extends Model
/**
* Set the days parameter. If an array is passed, it's
* AND'd together to create the mask value
*
* @param array|int $val
*/
public function setDaysAttribute($val): void
@@ -205,7 +214,6 @@ class Flight extends Model
/**
* Relationship
*/
public function airline()
{
return $this->belongsTo(Airline::class, 'airline_id');

View File

@@ -6,9 +6,9 @@ use App\Interfaces\Model;
/**
* Class FlightField
*
* @property string name
* @property string slug
* @package App\Models
*/
class FlightField extends Model
{
@@ -31,6 +31,7 @@ class FlightField extends Model
/**
* When setting the name attribute, also set the slug
*
* @param $name
*/
public function setNameAttribute($name): void

View File

@@ -6,10 +6,10 @@ use App\Interfaces\Model;
/**
* Class FlightFieldValue
*
* @property string flight_id
* @property string name
* @property string value
* @package App\Models
*/
class FlightFieldValue extends Model
{
@@ -36,7 +36,6 @@ class FlightFieldValue extends Model
/**
* Relationships
*/
public function flight()
{
return $this->belongsTo(Flight::class, 'flight_id');

View File

@@ -10,7 +10,6 @@ use GeoJson\Geometry\Point;
/**
* Return different points/features in GeoJSON format
* https://tools.ietf.org/html/rfc7946
* @package App\Models
*/
class GeoJson
{
@@ -37,16 +36,17 @@ class GeoJson
$point = [$lon, $lat];
$this->line_coords[] = [$lon, $lat];
if(array_key_exists('alt', $attrs)) {
if (array_key_exists('alt', $attrs)) {
$point[] = $attrs['alt'];
}
$this->point_coords[] = new Feature(new Point($point), $attrs);
++$this->counter;
$this->counter++;
}
/**
* Get the FeatureCollection for the line
*
* @return FeatureCollection
*/
public function getLine(): FeatureCollection
@@ -56,12 +56,13 @@ class GeoJson
}
return new FeatureCollection([
new Feature(new LineString($this->line_coords))
new Feature(new LineString($this->line_coords)),
]);
}
/**
* Get the feature collection of all the points
*
* @return FeatureCollection
*/
public function getPoints(): FeatureCollection

View File

@@ -12,6 +12,7 @@ use Carbon\Carbon;
/**
* Class Journal
*
* @property mixed id
* @property Money $balance
* @property string $currency
@@ -38,7 +39,7 @@ class Journal extends Model
protected $dates = [
'created_at',
'deleted_at',
'updated_at'
'updated_at',
];
/**
@@ -51,6 +52,7 @@ class Journal extends Model
/**
* Relationship
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function ledger()
@@ -60,6 +62,7 @@ class Journal extends Model
/**
* Relationship
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function transactions()
@@ -77,6 +80,7 @@ class Journal extends Model
/**
* @param Ledger $ledger
*
* @return Journal
*/
public function assignToLedger(Ledger $ledger)
@@ -87,7 +91,6 @@ class Journal extends Model
}
/**
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*/
@@ -99,9 +102,11 @@ class Journal extends Model
/**
* @param $value
* @return Money
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*
* @return Money
*/
public function getBalanceAttribute($value): Money
{
@@ -110,6 +115,7 @@ class Journal extends Model
/**
* @param $value
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*/
@@ -124,6 +130,7 @@ class Journal extends Model
/**
* @param Journal $object
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function transactionsReferencingObjectQuery($object)
@@ -136,10 +143,13 @@ class Journal extends Model
/**
* Get the credit only balance of the journal based on a given date.
*
* @param Carbon $date
* @return Money
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*
* @return Money
*/
public function getCreditBalanceOn(Carbon $date)
{
@@ -152,10 +162,13 @@ class Journal extends Model
/**
* Get the balance of the journal based on a given date.
*
* @param Carbon $date
* @return Money
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*
* @return Money
*/
public function getBalanceOn(Carbon $date)
{
@@ -165,9 +178,11 @@ class Journal extends Model
/**
* Get the balance of the journal as of right now, excluding future transactions.
* @return Money
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*
* @return Money
*/
public function getCurrentBalance()
{
@@ -176,9 +191,11 @@ class Journal extends Model
/**
* Get the balance of the journal. This "could" include future dates.
* @return Money
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*
* @return Money
*/
public function getBalance()
{

View File

@@ -15,10 +15,10 @@ use App\Models\Traits\ReferenceTrait;
* @property string memo
* @property string transaction_group
* @property string post_date
* @property integer credit
* @property integer debit
* @property int credit
* @property int debit
* @property string ref_model
* @property integer ref_model_id
* @property int ref_model_id
* @property Journal journal
*/
class JournalTransaction extends Model
@@ -39,7 +39,7 @@ class JournalTransaction extends Model
'tags',
'ref_model',
'ref_model_id',
'post_date'
'post_date',
];
protected $casts = [

View File

@@ -12,7 +12,7 @@ use Carbon\Carbon;
/**
* Class Journal
* @package Scottlaurent\Accounting
*
* @property Money $balance
* @property string $currency
* @property Carbon $updated_at
@@ -23,9 +23,6 @@ class Ledger extends Model
{
public $table = 'ledgers';
/**
*
*/
public function journals()
{
return $this->hasMany(Journal::class);
@@ -40,7 +37,6 @@ class Ledger extends Model
}
/**
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*/
@@ -56,7 +52,6 @@ class Ledger extends Model
}
/**
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*/

View File

@@ -6,7 +6,6 @@ use App\Interfaces\Model;
/**
* Class Navdata
* @package App\Models
*/
class Navdata extends Model
{
@@ -33,6 +32,7 @@ class Navdata extends Model
/**
* Make sure the ID is in all caps
*
* @param $id
*/
public function setIdAttribute($id): void

View File

@@ -6,7 +6,6 @@ use App\Interfaces\Model;
/**
* Class News
* @package App\Models
*/
class News extends Model
{
@@ -26,7 +25,6 @@ class News extends Model
/**
* FOREIGN KEYS
*/
public function user()
{
return $this->belongsTo(User::class, 'user_id');

View File

@@ -7,7 +7,6 @@ use App\Support\ICAO;
/**
* Class AircraftObserver
* @package App\Models\Observers
*/
class AircraftObserver
{

View File

@@ -6,7 +6,6 @@ use App\Models\Airport;
/**
* Make sure that the fields are properly capitalized
* @package App\Models\Observers
*/
class AirportObserver
{

View File

@@ -6,12 +6,12 @@ use App\Models\Journal;
/**
* Class JournalObserver
* @package App\Models\Observers
*/
class JournalObserver
{
/**
* @param Journal $journal
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*/

View File

@@ -6,12 +6,12 @@ use App\Models\JournalTransaction;
/**
* Class JournalTransactionObserver
* @package App\Models\Observers
*/
class JournalTransactionObserver
{
/**
* Set the ID to a UUID
*
* @param JournalTransaction $transaction
*/
public function creating(JournalTransaction $transaction): void
@@ -23,6 +23,7 @@ class JournalTransactionObserver
/**
* After transaction is saved, adjust the journal balance
*
* @param JournalTransaction $transaction
*/
public function saved(JournalTransaction $transaction): void
@@ -43,6 +44,7 @@ class JournalTransactionObserver
/**
* After transaction is deleted, adjust the balance on the journal
*
* @param JournalTransaction $transaction
*/
public function deleted(JournalTransaction $transaction): void

View File

@@ -6,7 +6,6 @@ use App\Models\Setting;
/**
* Class SettingObserver
* @package App\Models\Observers
*/
class SettingObserver
{

View File

@@ -4,7 +4,6 @@ namespace App\Models\Observers;
/**
* Create a slug from a name
* @package App\Models\Observers
*/
class Sluggable
{

View File

@@ -6,7 +6,6 @@ use App\Models\Subfleet;
/**
* Class SubfleetObserver
* @package App\Models\Observers
*/
class SubfleetObserver
{

View File

@@ -16,13 +16,14 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
/**
* Class Pirep
*
* @property string id
* @property string flight_number
* @property string route_code
* @property string route_leg
* @property integer airline_id
* @property integer user_id
* @property integer aircraft_id
* @property int airline_id
* @property int user_id
* @property int aircraft_id
* @property Aircraft aircraft
* @property Airline airline
* @property Airport arr_airport
@@ -31,13 +32,13 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
* @property string dpt_airport_id
* @property Carbon block_off_time
* @property Carbon block_on_time
* @property integer block_time
* @property integer flight_time In minutes
* @property integer planned_flight_time
* @property double distance
* @property double planned_distance
* @property int block_time
* @property int flight_time In minutes
* @property int planned_flight_time
* @property float distance
* @property float planned_distance
* @property string route
* @property integer score
* @property int score
* @property User user
* @property Flight|null flight
* @property Collection fields
@@ -49,7 +50,6 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
* @property bool read_only
* @property Acars position
* @property Acars[] acars
* @package App\Models
*/
class Pirep extends Model
{
@@ -59,7 +59,8 @@ class Pirep extends Model
public $incrementing = false;
/** The form wants this */
public $hours, $minutes;
public $hours;
public $minutes;
protected $fillable = [
'id',
@@ -137,11 +138,12 @@ class Pirep extends Model
/**
* Get the flight ident, e.,g JBU1900
*
* @return string
*/
public function getIdentAttribute(): string
{
#$flight_id = $this->airline->code;
//$flight_id = $this->airline->code;
$flight_id = $this->flight_number;
if (filled($this->route_code)) {
@@ -157,6 +159,7 @@ class Pirep extends Model
/**
* Return the block off time in carbon format
*
* @return Carbon
*/
public function getBlockOffTimeAttribute()
@@ -164,12 +167,11 @@ class Pirep extends Model
if (array_key_exists('block_off_time', $this->attributes)) {
return new Carbon($this->attributes['block_off_time']);
}
return null;
}
/**
* Return the block on time
*
* @return Carbon
*/
public function getBlockOnTimeAttribute()
@@ -177,12 +179,11 @@ class Pirep extends Model
if (array_key_exists('block_on_time', $this->attributes)) {
return new Carbon($this->attributes['block_on_time']);
}
return null;
}
/**
* Return the block on time
*
* @return Carbon
*/
public function getSubmittedAtAttribute()
@@ -190,18 +191,17 @@ class Pirep extends Model
if (array_key_exists('submitted_at', $this->attributes)) {
return new Carbon($this->attributes['submitted_at']);
}
return null;
}
/**
* Return a new Length unit so conversions can be made
*
* @return int|Distance
*/
public function getDistanceAttribute()
{
if (!array_key_exists('distance', $this->attributes)) {
return null;
return;
}
try {
@@ -220,6 +220,7 @@ class Pirep extends Model
/**
* Set the distance unit, convert to our internal default unit
*
* @param $value
*/
public function setDistanceAttribute($value): void
@@ -242,12 +243,13 @@ class Pirep extends Model
/**
* Return a new Fuel unit so conversions can be made
*
* @return int|Fuel
*/
public function getFuelUsedAttribute()
{
if (!array_key_exists('fuel_used', $this->attributes)) {
return null;
return;
}
try {
@@ -263,12 +265,13 @@ class Pirep extends Model
/**
* Return the planned_distance in a converter class
*
* @return int|Distance
*/
public function getPlannedDistanceAttribute()
{
if (!array_key_exists('planned_distance', $this->attributes)) {
return null;
return;
}
try {
@@ -291,11 +294,11 @@ class Pirep extends Model
public function getProgressPercentAttribute()
{
$upper_bound = $this->distance['nmi'];
if($this->planned_distance) {
if ($this->planned_distance) {
$upper_bound = $this->planned_distance['nmi'];
}
if(!$upper_bound) {
if (!$upper_bound) {
$upper_bound = 1;
}
@@ -311,16 +314,16 @@ class Pirep extends Model
$custom_fields = PirepField::all();
$field_values = PirepFieldValue::where('pirep_id', $this->id)->get();
# Merge the field values into $fields
foreach($custom_fields as $field) {
// Merge the field values into $fields
foreach ($custom_fields as $field) {
$has_value = $field_values->firstWhere('slug', $field->slug);
if(!$has_value) {
if (!$has_value) {
$field_values->push(new PirepFieldValue([
'pirep_id' => $this->id,
'name' => $field->name,
'slug' => $field->slug,
'value' => '',
'source' => PirepFieldSource::MANUAL
'name' => $field->name,
'slug' => $field->slug,
'value' => '',
'source' => PirepFieldSource::MANUAL,
]));
}
}
@@ -330,6 +333,7 @@ class Pirep extends Model
/**
* Look up the flight, based on the PIREP flight info
*
* @return Flight|null
*/
public function getFlightAttribute(): ?Flight
@@ -353,6 +357,7 @@ class Pirep extends Model
/**
* Set the amount of fuel used
*
* @param $value
*/
public function setFuelUsedAttribute($value)
@@ -368,6 +373,7 @@ class Pirep extends Model
/**
* Set the distance unit, convert to our internal default unit
*
* @param $value
*/
public function setPlannedDistanceAttribute($value)
@@ -383,6 +389,7 @@ class Pirep extends Model
/**
* Do some cleanup on the route
*
* @param $route
*/
public function setRouteAttribute($route): void
@@ -401,16 +408,19 @@ class Pirep extends Model
/**
* Check if this PIREP is allowed to be updated
*
* @return bool
*/
public function allowedUpdates(): bool
{
return ! $this->getReadOnlyAttribute();
return !$this->getReadOnlyAttribute();
}
/**
* Return a custom field value
*
* @param $field_name
*
* @return string
*/
public function field($field_name): string
@@ -426,7 +436,6 @@ class Pirep extends Model
/**
* Foreign Keys
*/
public function acars()
{
return $this->hasMany(Acars::class, 'pirep_id')

View File

@@ -9,7 +9,6 @@ use App\Interfaces\Model;
*
* @property string pirep_id
* @property int user_id
* @package App\Models
*/
class PirepComment extends Model
{

View File

@@ -6,7 +6,6 @@ use App\Interfaces\Model;
/**
* Class PirepFare
* @package App\Models
*/
class PirepFare extends Model
{
@@ -30,7 +29,6 @@ class PirepFare extends Model
/**
* Relationships
*/
public function fare()
{
return $this->belongsTo(Fare::class, 'fare_id');

View File

@@ -6,9 +6,9 @@ use App\Interfaces\Model;
/**
* Class PirepField
*
* @property string name
* @property string slug
* @package App\Models
*/
class PirepField extends Model
{
@@ -31,6 +31,7 @@ class PirepField extends Model
/**
* When setting the name attribute, also set the slug
*
* @param $name
*/
public function setNameAttribute($name): void

View File

@@ -7,7 +7,6 @@ use App\Models\Enums\PirepFieldSource;
/**
* Class PirepFieldValue
* @package App\Models
*/
class PirepFieldValue extends Model
{
@@ -31,6 +30,7 @@ class PirepFieldValue extends Model
/**
* If it was filled in from ACARS, then it's read only
*
* @return bool
*/
public function getReadOnlyAttribute()
@@ -50,7 +50,6 @@ class PirepFieldValue extends Model
/**
* Foreign Keys
*/
public function pirep()
{
return $this->belongsTo(Pirep::class, 'pirep_id');

View File

@@ -6,10 +6,10 @@ use App\Interfaces\Model;
/**
* Class Rank
*
* @property int hours
* @property float manual_base_pay_rate
* @property float acars_base_pay_rate
* @package App\Models
*/
class Rank extends Model
{

View File

@@ -6,6 +6,7 @@ use App\Interfaces\Model;
/**
* Class Setting
*
* @property string id
* @property string name
* @property string key
@@ -14,7 +15,6 @@ use App\Interfaces\Model;
* @property string type
* @property string options
* @property string description
* @package App\Models
*/
class Setting extends Model
{
@@ -39,6 +39,7 @@ class Setting extends Model
/**
* @param $key
*
* @return mixed
*/
public static function formatKey($key)
@@ -48,6 +49,7 @@ class Setting extends Model
/**
* Force formatting the key
*
* @param $id
*/
public function setIdAttribute($id): void
@@ -58,6 +60,7 @@ class Setting extends Model
/**
* Set the key to lowercase
*
* @param $key
*/
public function setKeyAttribute($key): void

View File

@@ -8,6 +8,7 @@ use App\Models\Traits\ExpensableTrait;
/**
* Class Subfleet
*
* @property int id
* @property string type
* @property string name
@@ -16,7 +17,6 @@ use App\Models\Traits\ExpensableTrait;
* @property float cost_block_hour
* @property float cost_delay_minute
* @property Airline airline
* @package App\Models
*/
class Subfleet extends Model
{
@@ -59,14 +59,13 @@ class Subfleet extends Model
*/
public function setTypeAttribute($type)
{
$type = str_replace([' ', ','], array('-', ''), $type);
$type = str_replace([' ', ','], ['-', ''], $type);
$this->attributes['type'] = $type;
}
/**
* Relationships
*/
public function aircraft()
{
return $this->hasMany(Aircraft::class, 'subfleet_id')

View File

@@ -12,13 +12,14 @@ trait ExpensableTrait
/**
* Morph to Expenses.
*
* @return mixed
*/
public function expenses()
{
return $this->morphMany(
Expense::class,
'expenses', # overridden by the next two anyway
'expenses', // overridden by the next two anyway
'ref_model',
'ref_model_id'
);

View File

@@ -8,13 +8,14 @@ trait FilesTrait
{
/**
* Morph to type of File
*
* @return mixed
*/
public function files()
{
return $this->morphMany(
File::class,
'files', # overridden by the next two anyway
'files', // overridden by the next two anyway
'ref_model',
'ref_model_id'
);

View File

@@ -8,8 +8,9 @@ use Hashids\Hashids;
trait HashIdTrait
{
/**
* @return string
* @throws \Hashids\HashidsException
*
* @return string
*/
final protected static function createNewHashId(): string
{
@@ -20,6 +21,7 @@ trait HashIdTrait
/**
* Register callbacks
*
* @throws \Hashids\HashidsException
*/
final protected static function bootHashIdTrait(): void

View File

@@ -30,8 +30,10 @@ trait JournalTrait
* Initialize a journal for a given model object
*
* @param string $currency_code
* @return Journal
*
* @throws \Exception
*
* @return Journal
*/
public function initJournal($currency_code = 'USD')
{

View File

@@ -4,14 +4,15 @@ namespace App\Models\Traits;
/**
* Trait ReferenceTrait
*
* @property \App\Interfaces\Model $ref_model
* @property mixed $ref_model_id
* @package App\Models\Traits
*/
trait ReferenceTrait
{
/**
* @param \App\Interfaces\Model $object
*
* @return self
*/
public function referencesObject($object)
@@ -25,12 +26,13 @@ trait ReferenceTrait
/**
* Return an instance of the object or null
*
* @return \App\Interfaces\Model|null
*/
public function getReferencedObject()
{
if (!$this->ref_model || !$this->ref_model_id) {
return null;
return;
}
if ($this->ref_model === __CLASS__) {
@@ -38,11 +40,11 @@ trait ReferenceTrait
}
try {
$klass = new $this->ref_model;
$klass = new $this->ref_model();
$obj = $klass->find($this->ref_model_id);
return $obj;
} catch (\Exception $e) {
return null;
return;
}
}
}

View File

@@ -10,7 +10,7 @@ use Illuminate\Notifications\Notifiable;
use Laratrust\Traits\LaratrustUserTrait;
/**
* @property integer id
* @property int id
* @property string name
* @property string email
* @property string password
@@ -111,6 +111,7 @@ class User extends Authenticatable
/**
* Shorthand for getting the timezone
*
* @return string
*/
public function getTzAttribute(): string
@@ -120,6 +121,7 @@ class User extends Authenticatable
/**
* Shorthand for setting the timezone
*
* @param $value
*/
public function setTzAttribute($value)
@@ -128,21 +130,22 @@ class User extends Authenticatable
}
/**
* Return a File model
*/
* Return a File model
*/
public function getAvatarAttribute()
{
if (!$this->attributes['avatar']) {
return null;
return;
}
return new File([
'path' => $this->attributes['avatar']
'path' => $this->attributes['avatar'],
]);
}
/**
* @param mixed $size Size of the gravatar, in pixels
*
* @return string
*/
public function gravatar($size = null)
@@ -162,7 +165,6 @@ class User extends Authenticatable
/**
* Foreign Keys
*/
public function airline()
{
return $this->belongsTo(Airline::class, 'airline_id');
@@ -198,6 +200,7 @@ class User extends Authenticatable
/**
* The bid rows
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function bids()

View File

@@ -6,7 +6,6 @@ use App\Interfaces\Model;
/**
* Class UserAward
* @package App\Models
*/
class UserAward extends Model
{
@@ -14,7 +13,7 @@ class UserAward extends Model
protected $fillable = [
'user_id',
'award_id'
'award_id',
];
/**