feat:complement wishlist for dashboard side
This commit is contained in:
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Account;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Favorite;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class FavoriteController extends Controller
|
||||||
|
{
|
||||||
|
public function toggle($type, $id)
|
||||||
|
{
|
||||||
|
$query = Favorite::where('user_id', Auth::id());
|
||||||
|
|
||||||
|
if ($type === 'flight') {
|
||||||
|
$query->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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Account;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Favorite;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class WishlistController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$favorites = Favorite::query()
|
||||||
|
->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'));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,247 @@
|
|||||||
|
@extends('account.layouts.app')
|
||||||
|
|
||||||
|
@section('title', 'علاقه مندی ها')
|
||||||
|
|
||||||
|
@section('account-content')
|
||||||
|
|
||||||
|
<div class="col-lg-9">
|
||||||
|
|
||||||
|
<div class="user-profile-wrapper">
|
||||||
|
|
||||||
|
<div class="user-profile-card">
|
||||||
|
|
||||||
|
<h4 class="user-profile-card-title">
|
||||||
|
فهرست علاقه مندی ها
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
<div class="row mt-30">
|
||||||
|
|
||||||
|
@forelse($favorites as $favorite)
|
||||||
|
@if($favorite->flight)
|
||||||
|
|
||||||
|
@php
|
||||||
|
$flight = $favorite->flight;
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<div class="col-md-6 col-lg-6">
|
||||||
|
|
||||||
|
<div class="flight-item">
|
||||||
|
|
||||||
|
<div class="flight-img">
|
||||||
|
|
||||||
|
<img
|
||||||
|
src="{{ asset('assets/img/flight/01.jpg') }}"
|
||||||
|
alt=""
|
||||||
|
>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="flight-content">
|
||||||
|
|
||||||
|
<div class="flight-title">
|
||||||
|
|
||||||
|
<div class="flight-title-info">
|
||||||
|
|
||||||
|
<img
|
||||||
|
src="{{ asset('assets/img/flight/airline-1.png') }}"
|
||||||
|
alt=""
|
||||||
|
>
|
||||||
|
|
||||||
|
<h4>
|
||||||
|
<a href="{{ route('flights.show', $flight->id) }}">
|
||||||
|
|
||||||
|
{{ $flight->departureAirport->city->name }}
|
||||||
|
|
||||||
|
<i class="far fa-exchange"></i>
|
||||||
|
|
||||||
|
{{ $flight->arrivalAirport->city->name }}
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<p class="flight-date">
|
||||||
|
|
||||||
|
<i class="far fa-calendar-days"></i>
|
||||||
|
|
||||||
|
{{ $flight->departure_time->toJalali()->format('Y/m/d H:i') }}
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="flight-bottom">
|
||||||
|
|
||||||
|
<div class="flight-price">
|
||||||
|
|
||||||
|
از
|
||||||
|
|
||||||
|
<span>
|
||||||
|
{{ number_format($flight->price) }}
|
||||||
|
تومان
|
||||||
|
</span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="flight-text-btn">
|
||||||
|
|
||||||
|
<a href="{{ route('flights.show', $flight->id) }}">
|
||||||
|
|
||||||
|
نمایش جزئیات
|
||||||
|
|
||||||
|
<i class="fas fa-arrow-left"></i>
|
||||||
|
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@elseif($favorite->tour)
|
||||||
|
|
||||||
|
@php
|
||||||
|
$tour = $favorite->tour;
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<div class="col-md-6 col-lg-6">
|
||||||
|
|
||||||
|
<div class="flight-item">
|
||||||
|
|
||||||
|
<div class="flight-img">
|
||||||
|
|
||||||
|
<img
|
||||||
|
src="{{ asset('assets/img/flight/01.jpg') }}"
|
||||||
|
alt=""
|
||||||
|
>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="flight-content">
|
||||||
|
|
||||||
|
<div class="flight-title">
|
||||||
|
|
||||||
|
<div class="flight-title-info">
|
||||||
|
|
||||||
|
<h4>
|
||||||
|
|
||||||
|
<a href="{{ route('tours.show', $tour->id) }}">
|
||||||
|
|
||||||
|
{{ $tour->title }}
|
||||||
|
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<p class="flight-date">
|
||||||
|
|
||||||
|
<i class="far fa-clock"></i>
|
||||||
|
|
||||||
|
{{ $tour->duration }} روز
|
||||||
|
|
||||||
|
@if($tour->duration > 1)
|
||||||
|
و {{ $tour->duration - 1 }} شب
|
||||||
|
@endif
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
|
||||||
|
<p>
|
||||||
|
|
||||||
|
<i class="far fa-location-dot"></i>
|
||||||
|
|
||||||
|
{{ $tour->origin }}
|
||||||
|
|
||||||
|
<i class="far fa-arrow-left mx-1"></i>
|
||||||
|
|
||||||
|
{{ $tour->destination }}
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="flight-bottom">
|
||||||
|
|
||||||
|
<div class="flight-price">
|
||||||
|
|
||||||
|
از
|
||||||
|
|
||||||
|
<span>
|
||||||
|
|
||||||
|
{{ number_format($tour->price) }}
|
||||||
|
|
||||||
|
تومان
|
||||||
|
|
||||||
|
</span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="flight-text-btn">
|
||||||
|
|
||||||
|
<a href="{{ route('tours.show', $tour->id) }}">
|
||||||
|
|
||||||
|
نمایش جزئیات
|
||||||
|
|
||||||
|
<i class="fas fa-arrow-left"></i>
|
||||||
|
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@empty
|
||||||
|
|
||||||
|
<div class="col-12">
|
||||||
|
|
||||||
|
<div class="text-center py-5">
|
||||||
|
|
||||||
|
<i class="far fa-heart fa-3x mb-3"></i>
|
||||||
|
|
||||||
|
<h5>
|
||||||
|
هنوز موردی به علاقه مندی ها اضافه نکرده اید.
|
||||||
|
</h5>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endforelse
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{ $favorites->links() }}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Http\Controllers\Account\BookingController;
|
||||||
|
use App\Http\Controllers\Account\EditProfileController;
|
||||||
|
use App\Http\Controllers\Account\FavoriteController;
|
||||||
|
use App\Http\Controllers\Account\ProfileController;
|
||||||
|
use App\Http\Controllers\Account\WishlistController;
|
||||||
|
use App\Http\Controllers\Account\CommentStatusController;
|
||||||
use App\Http\Controllers\CommentController;
|
use App\Http\Controllers\CommentController;
|
||||||
use App\Http\Controllers\FlightController;
|
use App\Http\Controllers\FlightController;
|
||||||
use App\Http\Controllers\IndexController;
|
use App\Http\Controllers\IndexController;
|
||||||
@@ -25,9 +31,37 @@ Route::prefix('tours')
|
|||||||
Route::get('/', 'index')->name('index');
|
Route::get('/', 'index')->name('index');
|
||||||
Route::get('/{tour}', 'show')->name('show');
|
Route::get('/{tour}', 'show')->name('show');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::controller(CommentController::class)
|
Route::controller(CommentController::class)
|
||||||
->group(function () {
|
->group(function () {
|
||||||
Route::post('/flights/{flight}/comments', 'flightStore')->name('flights.comments.store');
|
Route::post('/flights/{flight}/comments', 'flightStore')->name('flights.comments.store');
|
||||||
Route::post('/tours/{tour}/comments', 'tourStore')->name('tours.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');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user