refactor: update models relations
This commit is contained in:
+29
-19
@@ -12,37 +12,47 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Airport
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $city
|
||||
* @property string $country
|
||||
* @property int $city_id
|
||||
* @property int $status
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
*
|
||||
* @property City $city
|
||||
* @property Collection|Flight[] $flights
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class Airport extends Model
|
||||
{
|
||||
protected $table = 'airports';
|
||||
public static $snakeAttributes = false;
|
||||
protected $table = 'airports';
|
||||
public static $snakeAttributes = false;
|
||||
|
||||
protected $casts = [
|
||||
'status' => 'int'
|
||||
];
|
||||
protected $casts = [
|
||||
'city_id' => 'int',
|
||||
'status' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'city',
|
||||
'country',
|
||||
'status'
|
||||
];
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'city_id',
|
||||
'status'
|
||||
];
|
||||
|
||||
public function flights()
|
||||
{
|
||||
return $this->hasMany(Flight::class, 'destination_airport_id');
|
||||
}
|
||||
public function city()
|
||||
{
|
||||
return $this->belongsTo(City::class);
|
||||
}
|
||||
|
||||
public function originFlights()
|
||||
{
|
||||
return $this->hasMany(Flight::class, 'origin_airport_id');
|
||||
}
|
||||
|
||||
public function destinationFlights()
|
||||
{
|
||||
return $this->hasMany(Flight::class, 'destination_airport_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user