Airline <> Aircraft Relationships (#1338)

* Aircraft relationship

* Airline relationship

* Flight and Pirep Relationships

* Style and logic fix
This commit is contained in:
B.Fatih KOZ 2021-11-02 15:40:50 +03:00 committed by GitHub
parent 471464272f
commit f498ad3bba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -115,11 +115,21 @@ class Aircraft extends Model
/**
* foreign keys
*/
public function airline()
{
return $this->belongsToThrough(Airline::class, Subfleet::class);
}
public function airport()
{
return $this->belongsTo(Airport::class, 'airport_id');
}
public function pireps()
{
return $this->hasMany(Pirep::class, 'aircraft_id');
}
public function subfleet()
{
return $this->belongsTo(Subfleet::class, 'subfleet_id');

View File

@ -103,6 +103,11 @@ class Airline extends Model
return $this->hasMany(Subfleet::class, 'airline_id');
}
public function aircraft()
{
return $this->hasManyThrough(Aircraft::class, Subfleet::class);
}
public function flights()
{
return $this->belongsTo(Flight::class, 'airline_id');