From b1caa3fbfd1d5ae98e77e3356a3d97369a795291 Mon Sep 17 00:00:00 2001 From: mina-esn Date: Tue, 18 Aug 2026 16:49:35 +0330 Subject: [PATCH] feat: add routes, model, controller and update related models relations --- .../Account/FavoriteController.php | 35 ++++++++++++++++ app/Models/Favorite.php | 40 +++++++++++++++++++ app/Models/Flight.php | 4 ++ app/Models/Tour.php | 4 ++ app/Models/User.php | 4 ++ .../views/account/layouts/sidebar.blade.php | 2 +- routes/web.php | 14 +++++++ 7 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/Account/FavoriteController.php create mode 100644 app/Models/Favorite.php diff --git a/app/Http/Controllers/Account/FavoriteController.php b/app/Http/Controllers/Account/FavoriteController.php new file mode 100644 index 0000000..a8d6550 --- /dev/null +++ b/app/Http/Controllers/Account/FavoriteController.php @@ -0,0 +1,35 @@ + 'int', + 'tour_id' => 'int', + 'flight_id' => 'int' + ]; + + protected $fillable = [ + 'user_id', + 'tour_id', + 'flight_id' + ]; +} diff --git a/app/Models/Flight.php b/app/Models/Flight.php index ac79abf..e00a439 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -150,5 +150,9 @@ class Flight extends Model { return $this->hasMany(Comment::class, 'flight_id'); } + public function favorites() + { + return $this->hasMany(Favorite::class); + } } diff --git a/app/Models/Tour.php b/app/Models/Tour.php index 0b322d8..b432d52 100644 --- a/app/Models/Tour.php +++ b/app/Models/Tour.php @@ -100,4 +100,8 @@ class Tour extends Model { return $this->hasMany(Comment::class, 'tour_id'); } + public function favorites() + { + return $this->hasMany(Favorite::class); + } } diff --git a/app/Models/User.php b/app/Models/User.php index 9f8d6b0..27f9898 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -108,4 +108,8 @@ class User extends Authenticate { return $this->hasMany(Comment::class, 'user_id'); } + public function favorites() + { + return $this->hasMany(Favorite::class); + } } diff --git a/resources/views/account/layouts/sidebar.blade.php b/resources/views/account/layouts/sidebar.blade.php index 18b70ae..020a51e 100644 --- a/resources/views/account/layouts/sidebar.blade.php +++ b/resources/views/account/layouts/sidebar.blade.php @@ -11,7 +11,7 @@