From 31cef139b4c7397c0d496989d9ef13732d028884 Mon Sep 17 00:00:00 2001 From: mina-esn Date: Sun, 16 Aug 2026 11:27:36 +0330 Subject: [PATCH] feat: add Province model and update City model relations --- app/Models/City.php | 15 ++++++++++++ app/Models/Province.php | 53 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 app/Models/Province.php diff --git a/app/Models/City.php b/app/Models/City.php index 9fd4be6..e5ddc35 100644 --- a/app/Models/City.php +++ b/app/Models/City.php @@ -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); + } } diff --git a/app/Models/Province.php b/app/Models/Province.php new file mode 100644 index 0000000..a310ebb --- /dev/null +++ b/app/Models/Province.php @@ -0,0 +1,53 @@ + 'int' + ]; + + protected $fillable = [ + 'name', + 'status' + ]; + + public function cities() + { + return $this->hasMany(City::class); + } + + public function users() + { + return $this->hasMany(User::class); + } +}