fix:change models problems and routes
This commit is contained in:
+12
-2
@@ -14,10 +14,11 @@ use Illuminate\Database\Eloquent\Model;
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $city
|
||||
* @property int|null $city_id
|
||||
* @property string $code
|
||||
* @property string $country
|
||||
*
|
||||
* @property City|null $city
|
||||
* @property Collection|Flight[] $flights
|
||||
*
|
||||
* @package App\Models
|
||||
@@ -28,13 +29,22 @@ class Airport extends Model
|
||||
public $timestamps = false;
|
||||
public static $snakeAttributes = false;
|
||||
|
||||
protected $casts = [
|
||||
'city_id' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'city',
|
||||
'city_id',
|
||||
'code',
|
||||
'country'
|
||||
];
|
||||
|
||||
public function city()
|
||||
{
|
||||
return $this->belongsTo(City::class);
|
||||
}
|
||||
|
||||
public function flights()
|
||||
{
|
||||
return $this->hasMany(Flight::class, 'departure_airport_id');
|
||||
|
||||
+11
-6
@@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Flight
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $arrival_aiport_id
|
||||
* @property int $departure_airport_id
|
||||
@@ -27,7 +27,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property int $status
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
*
|
||||
* @property Airline $airline
|
||||
* @property File $file
|
||||
* @property Airport $airport
|
||||
@@ -72,16 +72,21 @@ class Flight extends Model
|
||||
{
|
||||
return $this->belongsTo(Airline::class);
|
||||
}
|
||||
public function departureAirport()
|
||||
{
|
||||
return $this->belongsTo(Airport::class, 'departure_airport_id');
|
||||
}
|
||||
|
||||
public function arrivalAirport()
|
||||
{
|
||||
return $this->belongsTo(Airport::class, 'arrival_aiport_id');
|
||||
}
|
||||
|
||||
public function file()
|
||||
{
|
||||
return $this->belongsTo(File::class);
|
||||
}
|
||||
|
||||
public function airport()
|
||||
{
|
||||
return $this->belongsTo(Airport::class, 'departure_airport_id');
|
||||
}
|
||||
|
||||
public function bookings()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user