feat: add Province model and update City model relations
This commit is contained in:
@@ -16,6 +16,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $county_id
|
||||
* @property int $province_id
|
||||
* @property string $name
|
||||
* @property int $status
|
||||
* @property Carbon $created_at
|
||||
@@ -23,7 +24,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @property string|null $deleted_at
|
||||
*
|
||||
* @property Country $country
|
||||
* @property Province $province
|
||||
* @property Collection|Tour[] $tours
|
||||
* @property Collection|User[] $users
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
@@ -35,11 +38,13 @@ class City extends Model
|
||||
|
||||
protected $casts = [
|
||||
'county_id' => 'int',
|
||||
'province_id' => 'int',
|
||||
'status' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'county_id',
|
||||
'province_id',
|
||||
'name',
|
||||
'status'
|
||||
];
|
||||
@@ -49,8 +54,18 @@ class City extends Model
|
||||
return $this->belongsTo(Country::class, 'county_id');
|
||||
}
|
||||
|
||||
public function province()
|
||||
{
|
||||
return $this->belongsTo(Province::class);
|
||||
}
|
||||
|
||||
public function tours()
|
||||
{
|
||||
return $this->hasMany(Tour::class, 'destination_city_id');
|
||||
}
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user