From 7cdfcdbef294683963e87225af2bfb5bfe814fd7 Mon Sep 17 00:00:00 2001 From: mina-esn Date: Tue, 18 Aug 2026 09:28:06 +0330 Subject: [PATCH] feat: update user and flight models and add comment and admin models --- app/Models/Admin.php | 76 ++++++++++++++++++++++++++++++++++++++ app/Models/Comment.php | 83 ++++++++++++++++++++++++++++++++++++++++++ app/Models/Flight.php | 6 +-- app/Models/Tour.php | 60 ++++++++++++++++-------------- app/Models/User.php | 4 ++ 5 files changed, 198 insertions(+), 31 deletions(-) create mode 100644 app/Models/Admin.php create mode 100644 app/Models/Comment.php diff --git a/app/Models/Admin.php b/app/Models/Admin.php new file mode 100644 index 0000000..7c67cc1 --- /dev/null +++ b/app/Models/Admin.php @@ -0,0 +1,76 @@ + 'int', + 'role' => 'int', + 'status' => 'int', + 'last_login_at' => 'datetime' + ]; + + protected $hidden = [ + 'password' + ]; + + protected $fillable = [ + 'first_name', + 'last_name', + 'username', + 'email', + 'mobile', + 'password', + 'file_id', + 'role', + 'status', + 'last_login_at' + ]; + + public function file() + { + return $this->belongsTo(File::class); + } + + public function comments() + { + return $this->hasMany(Comment::class); + } +} diff --git a/app/Models/Comment.php b/app/Models/Comment.php new file mode 100644 index 0000000..0decada --- /dev/null +++ b/app/Models/Comment.php @@ -0,0 +1,83 @@ + 'int', + 'admin_id' => 'int', + 'tour_id' => 'int', + 'flight_id' => 'int', + 'parent_id' => 'int', + 'status' => 'int' + ]; + + protected $fillable = [ + 'user_id', + 'admin_id', + 'tour_id', + 'flight_id', + 'parent_id', + 'guest_name', + 'guest_email', + 'content', + 'status' + ]; + + public function flight() + { + return $this->belongsTo(Flight::class); + } + + public function tour() + { + return $this->belongsTo(Tour::class); + } + + public function user() + { + return $this->belongsTo(User::class); + } + + public function admin() + { + return $this->belongsTo(Admin::class); + } +} diff --git a/app/Models/Flight.php b/app/Models/Flight.php index bf87071..ac79abf 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -146,9 +146,9 @@ class Flight extends Model { return $this->hasMany(Booking::class); } - - public function tours() + public function comments() { - return $this->hasMany(Tour::class, 'file_id'); + return $this->hasMany(Comment::class, 'flight_id'); } + } diff --git a/app/Models/Tour.php b/app/Models/Tour.php index 4307fcf..0b322d8 100644 --- a/app/Models/Tour.php +++ b/app/Models/Tour.php @@ -34,24 +34,28 @@ use Illuminate\Database\Eloquent\Model; */ class Tour extends Model { - protected $table = 'tours'; - public static $snakeAttributes = false; + protected $table = 'tours'; + public static $snakeAttributes = false; - protected $casts = [ - 'origin_city_id' => 'int', - 'destination_city_id' => 'int', - 'file_id' => 'int' - ]; + protected $casts = [ + 'origin_city_id' => 'int', + 'destination_city_id' => 'int', + 'file_id' => 'int', + 'tour_mode'=> 'int', + 'tour_scope' => 'int' + ]; - protected $fillable = [ - 'title', - 'summary', - 'description', - 'origin_city_id', - 'destination_city_id', - 'file_id', - 'tour_type' - ]; + protected $fillable = [ + 'title', + 'summary', + 'description', + 'origin_city_id', + 'destination_city_id', + 'file_id', + 'tour_type', + 'tour_mode', + 'tour_scope' + ]; #[Scope] protected function applySort(Builder $query, ?string $sort = null): void { @@ -73,27 +77,27 @@ class Tour extends Model } } - public function flight() - { - return $this->belongsTo(Flight::class, 'file_id'); - } public function originCity() { return $this->belongsTo(City::class, 'origin_city_id'); } - public function city() - { - return $this->belongsTo(City::class, 'destination_city_id'); - } + public function city() + { + return $this->belongsTo(City::class, 'destination_city_id'); + } - public function tourDepartures() - { - return $this->hasMany(TourDeparture::class , 'tour_id'); - } + public function tourDepartures() + { + return $this->hasMany(TourDeparture::class , 'tour_id'); + } public function file() { return $this->belongsTo(File::class, 'file_id'); } + public function comments() + { + return $this->hasMany(Comment::class, 'tour_id'); + } } diff --git a/app/Models/User.php b/app/Models/User.php index e3f4b0d..9f8d6b0 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -104,4 +104,8 @@ class User extends Authenticate { return $this->hasMany(Passenger::class); } + public function comments() + { + return $this->hasMany(Comment::class, 'user_id'); + } }