Add acars map page and show in-progress flights

This commit is contained in:
Nabeel Shahzad
2017-12-27 16:47:22 -06:00
parent a2e2a2a6a7
commit edca0644ff
103 changed files with 12380 additions and 827 deletions

View File

@@ -93,7 +93,8 @@ class Pirep extends BaseModel
public function acars()
{
return $this->hasMany('App\Models\Acars', 'pirep_id');
return $this->hasMany('App\Models\Acars', 'pirep_id')
->orderBy('created_at', 'desc');
}
public function aircraft()
@@ -118,12 +119,8 @@ class Pirep extends BaseModel
public function comments()
{
return $this->hasMany('App\Models\PirepComment', 'pirep_id');
}
public function events()
{
return $this->hasMany('App\Models\PirepEvent', 'pirep_id');
return $this->hasMany('App\Models\PirepComment', 'pirep_id')
->orderBy('created_at', 'desc');
}
public function fields()
@@ -141,14 +138,17 @@ class Pirep extends BaseModel
return $this->user();
}
public function route()
/**
* Relationship that holds the current position, but limits the ACARS
* relationship to only one row (the latest), to prevent an N+! problem
*/
public function position()
{
return [];
return $this->hasOne('App\Models\Acars', 'pirep_id')->latest();
}
public function user()
{
return $this->belongsTo('App\Models\User', 'user_id');
}
}

View File

@@ -1,45 +0,0 @@
<?php
namespace App\Models;
/**
* Class PirepEvent
*
* @package App\Models
*/
class PirepEvent extends BaseModel
{
public $table = 'pirep_fields';
public $fillable
= [
'name',
'value',
];
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts
= [
'name' => 'string',
'required' => 'integer',
];
/**
* Validation rules
*
* @var array
*/
public static $rules
= [
'name' => 'required',
];
public function pirep()
{
return $this->belongsTo('App\Models\Pirep', 'pirep_id');
}
}