Restrict relationship to FLIGHT_PATH #102

This commit is contained in:
Nabeel Shahzad
2018-01-01 10:38:45 -06:00
parent 078e26df57
commit fc52bdf166

View File

@@ -2,6 +2,7 @@
namespace App\Models; namespace App\Models;
use App\Models\Enums\AcarsType;
use App\Models\Traits\HashId; use App\Models\Traits\HashId;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
@@ -85,7 +86,8 @@ class Pirep extends BaseModel
public function acars() public function acars()
{ {
return $this->hasMany('App\Models\Acars', 'pirep_id') return $this->hasMany('App\Models\Acars', 'pirep_id')
->orderBy('created_at', 'asc'); ->where('type', AcarsType::FLIGHT_PATH)
->orderBy('created_at', 'asc');
} }
public function aircraft() public function aircraft()
@@ -135,7 +137,9 @@ class Pirep extends BaseModel
*/ */
public function position() public function position()
{ {
return $this->hasOne('App\Models\Acars', 'pirep_id')->latest(); return $this->hasOne('App\Models\Acars', 'pirep_id')
->where('type', AcarsType::FLIGHT_PATH)
->latest();
} }
public function user() public function user()