refactor: update models relations

This commit is contained in:
2026-08-16 17:00:01 +03:30
parent bd0e1aab31
commit a226931a77
5 changed files with 56 additions and 21 deletions
+29 -19
View File
@@ -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');
}
}