#48 Model/relationships for custom flight fields
This commit is contained in:
@@ -63,6 +63,10 @@ class Flight extends Model
|
||||
'arr_airport_id' => 'required',
|
||||
];
|
||||
|
||||
/**
|
||||
* Relationship
|
||||
*/
|
||||
|
||||
public function airline()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Airline', 'airline_id');
|
||||
@@ -83,6 +87,11 @@ class Flight extends Model
|
||||
return $this->belongsTo('App\Models\Airport', 'alt_airport_id');
|
||||
}
|
||||
|
||||
public function fields()
|
||||
{
|
||||
return $this->hasMany('App\Models\FlightFields', 'flight_id');
|
||||
}
|
||||
|
||||
public function subfleets()
|
||||
{
|
||||
return $this->belongsToMany('App\Models\Subfleet', 'subfleet_flight');
|
||||
|
||||
39
app/Models/FlightFields.php
Normal file
39
app/Models/FlightFields.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Eloquent as Model;
|
||||
|
||||
/**
|
||||
* Class Flight
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class FlightFields extends Model
|
||||
{
|
||||
|
||||
public $table = 'flight_fields';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public $fillable
|
||||
= [
|
||||
'flight_id',
|
||||
'name',
|
||||
'value',
|
||||
];
|
||||
|
||||
protected $casts = [];
|
||||
|
||||
public static $rules = [];
|
||||
|
||||
/**
|
||||
* Relationships
|
||||
*/
|
||||
|
||||
public function flight()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Flight', 'flight_id');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user