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