From 063d8f6d55c84cc5be324c6514f2f14940f3c23c Mon Sep 17 00:00:00 2001 From: Bahar Date: Tue, 18 Aug 2026 12:45:37 +0330 Subject: [PATCH] feat:complement wishlist for dashboard side --- .../Account/FavoriteController.php | 44 ++++ .../Account/WishlistController.php | 26 ++ resources/views/account/wishlist.blade.php | 247 ++++++++++++++++++ routes/web.php | 34 +++ 4 files changed, 351 insertions(+) create mode 100644 app/Http/Controllers/Account/FavoriteController.php create mode 100644 app/Http/Controllers/Account/WishlistController.php create mode 100644 resources/views/account/wishlist.blade.php diff --git a/app/Http/Controllers/Account/FavoriteController.php b/app/Http/Controllers/Account/FavoriteController.php new file mode 100644 index 0000000..9bbe505 --- /dev/null +++ b/app/Http/Controllers/Account/FavoriteController.php @@ -0,0 +1,44 @@ +where('flight_id', $id); + } elseif ($type === 'tour') { + $query->where('tour_id', $id); + } else { + abort(404); + } + + $favorite = $query->first(); + + if ($favorite) { + $favorite->delete(); + } else { + + $data = [ + 'user_id' => Auth::id(), + ]; + + if ($type === 'flight') { + $data['flight_id'] = $id; + } else { + $data['tour_id'] = $id; + } + + Favorite::create($data); + } + + return back(); + } +} diff --git a/app/Http/Controllers/Account/WishlistController.php b/app/Http/Controllers/Account/WishlistController.php new file mode 100644 index 0000000..13ca4f1 --- /dev/null +++ b/app/Http/Controllers/Account/WishlistController.php @@ -0,0 +1,26 @@ +where('user_id', Auth::id()) + ->with([ + 'flight.departureAirport.city', + 'flight.arrivalAirport.city', + 'flight.file', + 'tour.file', + ]) + ->orderByDesc('id') + ->paginate(); + + return view('account.wishlist', compact('favorites')); + } +} diff --git a/resources/views/account/wishlist.blade.php b/resources/views/account/wishlist.blade.php new file mode 100644 index 0000000..40882ff --- /dev/null +++ b/resources/views/account/wishlist.blade.php @@ -0,0 +1,247 @@ +@extends('account.layouts.app') + +@section('title', 'علاقه مندی ها') + +@section('account-content') + +
+ + + +
+ +@endsection diff --git a/routes/web.php b/routes/web.php index 7af5210..e8cd9a5 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,5 +1,11 @@ name('index'); Route::get('/{tour}', 'show')->name('show'); }); + Route::controller(CommentController::class) ->group(function () { Route::post('/flights/{flight}/comments', 'flightStore')->name('flights.comments.store'); Route::post('/tours/{tour}/comments', 'tourStore')->name('tours.comments.store'); }); + +Route::prefix('account')->name('account.')->middleware('auth')->group(function () { + + Route::get('profile', [ProfileController::class, 'index'])->name('profile'); + + Route::get('wishlist', [WishlistController::class, 'index']) + ->name('wishlist'); + + Route::prefix('edit-profile')->name('edit-profile.')->controller(EditProfileController::class)->group(function () { + + Route::get('/', 'index')->name('index'); + Route::put('/', 'post')->name('post'); + + }); + Route::post( + 'favorites/{type}/{id}/toggle', + [FavoriteController::class, 'toggle'] + )->name('favorites.toggle'); + + Route::get('comments', [CommentStatusController::class, 'index']) + ->name('comments'); + + Route::get('booking', [BookingController::class, 'index'])->name('booking'); +}); + + +