Add acars map page and show in-progress flights
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user