refactor: update models relations
This commit is contained in:
@@ -15,12 +15,13 @@ use Illuminate\Database\Eloquent\Model;
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $country
|
||||
* @property int $country_id
|
||||
* @property string $phone
|
||||
* @property int $status
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
* @property Country $country
|
||||
* @property Collection|Flight[] $flights
|
||||
*
|
||||
* @package App\Models
|
||||
@@ -31,16 +32,22 @@ class Airline extends Model
|
||||
public static $snakeAttributes = false;
|
||||
|
||||
protected $casts = [
|
||||
'country_id' => 'int',
|
||||
'status' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'country',
|
||||
'country_id',
|
||||
'phone',
|
||||
'status'
|
||||
];
|
||||
|
||||
public function country()
|
||||
{
|
||||
return $this->belongsTo(Country::class);
|
||||
}
|
||||
|
||||
public function flights()
|
||||
{
|
||||
return $this->hasMany(Flight::class);
|
||||
|
||||
+27
-17
@@ -15,34 +15,44 @@ use Illuminate\Database\Eloquent\Model;
|
||||
*
|
||||
* @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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
*
|
||||
* @property Country $country
|
||||
* @property Province $province
|
||||
* @property Collection|Airport[] $airports
|
||||
* @property Collection|Tour[] $tours
|
||||
* @property Collection|User[] $users
|
||||
*
|
||||
@@ -59,6 +60,11 @@ class City extends Model
|
||||
return $this->belongsTo(Province::class);
|
||||
}
|
||||
|
||||
public function airports()
|
||||
{
|
||||
return $this->hasMany(Airport::class);
|
||||
}
|
||||
|
||||
public function tours()
|
||||
{
|
||||
return $this->hasMany(Tour::class, 'destination_city_id');
|
||||
|
||||
@@ -21,6 +21,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @property Carbon $updated_at
|
||||
* @property string|null $deleted_at
|
||||
*
|
||||
* @property Collection|Airline[] $airlines
|
||||
* @property Collection|City[] $cities
|
||||
*
|
||||
* @package App\Models
|
||||
@@ -40,6 +41,11 @@ class Country extends Model
|
||||
'status'
|
||||
];
|
||||
|
||||
public function airlines()
|
||||
{
|
||||
return $this->hasMany(Airline::class);
|
||||
}
|
||||
|
||||
public function cities()
|
||||
{
|
||||
return $this->hasMany(City::class, 'county_id');
|
||||
|
||||
@@ -22,6 +22,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
* @property Collection|Flight[] $flights
|
||||
* @property Collection|User[] $users
|
||||
*
|
||||
* @package App\Models
|
||||
@@ -43,6 +44,11 @@ class File extends Model
|
||||
'path'
|
||||
];
|
||||
|
||||
public function flights()
|
||||
{
|
||||
return $this->hasMany(Flight::class);
|
||||
}
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
|
||||
Reference in New Issue
Block a user