chore: finalize project updates
This commit is contained in:
@@ -13,15 +13,15 @@ use Illuminate\Http\Request;
|
||||
|
||||
class TourController extends Controller
|
||||
{
|
||||
/**
|
||||
* لیست / آرشیو تورها با قابلیت فیلتر
|
||||
*/
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = Tour::query()
|
||||
->where('status', 1)
|
||||
->with(['travelType', 'flights']);
|
||||
|
||||
|
||||
|
||||
if ($request->filled('travel_type')) {
|
||||
$query->where('travel_type_id', $request->input('travel_type'));
|
||||
}
|
||||
@@ -44,15 +44,18 @@ class TourController extends Controller
|
||||
$query->latest();
|
||||
}
|
||||
|
||||
$tours = $query->paginate(9);
|
||||
$travelTypes = TravelType::where('status', 1)->get();
|
||||
if ($request->routeIs('index')) {
|
||||
|
||||
return view('tours.index', compact('tours', 'travelTypes'));
|
||||
$tours = $query->latest()->limit(4)->get();
|
||||
return view('index', compact('tours'));
|
||||
} else {
|
||||
|
||||
$tours = $query->latest()->paginate(2);
|
||||
$travelTypes = TravelType::where('status', 1)->get();
|
||||
return view('tours.index', compact('tours', 'travelTypes'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* نمایش جزئیات یک تور
|
||||
*/
|
||||
public function show(Tour $tour)
|
||||
{
|
||||
if ($tour->status != 1) {
|
||||
@@ -75,7 +78,7 @@ class TourController extends Controller
|
||||
->where('travel_type_id', $tour->travel_type_id)
|
||||
->where('id', '!=', $tour->id)
|
||||
->latest()
|
||||
->limit(4)
|
||||
->limit(3)
|
||||
->get();
|
||||
|
||||
$isFav = false;
|
||||
@@ -117,160 +120,3 @@ class TourController extends Controller
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//namespace App\Http\Controllers;
|
||||
//
|
||||
//use App\Models\Favorite;
|
||||
//use App\Models\Tour;
|
||||
//use App\Models\TravelType;
|
||||
//use Illuminate\Http\Request;
|
||||
//
|
||||
//class TourController extends Controller
|
||||
//{
|
||||
// /**
|
||||
// * لیست / آرشیو تورها با قابلیت فیلتر
|
||||
// */
|
||||
// public function index(Request $request)
|
||||
// {
|
||||
// $query = Tour::query()
|
||||
// ->where('status', 1)
|
||||
// ->with(['travelType', 'flights']);
|
||||
//
|
||||
// // فیلتر بر اساس نوع سفر
|
||||
// if ($request->filled('travel_type')) {
|
||||
// $query->where(
|
||||
// 'travel_type_id',
|
||||
// $request->input('travel_type')
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// // جستجو بر اساس عنوان
|
||||
// if ($request->filled('q')) {
|
||||
// $query->where(
|
||||
// 'title',
|
||||
// 'like',
|
||||
// '%' . $request->input('q') . '%'
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// // حداقل قیمت
|
||||
// if ($request->filled('price_min')) {
|
||||
// $query->where(
|
||||
// 'price',
|
||||
// '>=',
|
||||
// $request->input('price_min')
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// // حداکثر قیمت
|
||||
// if ($request->filled('price_max')) {
|
||||
// $query->where(
|
||||
// 'price',
|
||||
// '<=',
|
||||
// $request->input('price_max')
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// // مرتبسازی
|
||||
// if ($request->filled('sort')) {
|
||||
// $query->orderBy(
|
||||
// 'price',
|
||||
// $request->input('sort') === 'desc'
|
||||
// ? 'desc'
|
||||
// : 'asc'
|
||||
// );
|
||||
// } else {
|
||||
// $query->latest();
|
||||
// }
|
||||
//
|
||||
// // صفحهبندی
|
||||
// $tours = $query->paginate(9);
|
||||
//
|
||||
// // انواع سفر
|
||||
// $travelTypes = TravelType::where('status', 1)->get();
|
||||
//
|
||||
// return view(
|
||||
// 'tours.index',
|
||||
// compact('tours', 'travelTypes')
|
||||
// );
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * حذف فیلترها
|
||||
// */
|
||||
// public function removeFilters()
|
||||
// {
|
||||
// return redirect()->route('tours.index');
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * نمایش جزئیات یک تور
|
||||
// */
|
||||
// public function show(Tour $tour)
|
||||
// {
|
||||
// // فقط تورهای فعال قابل مشاهده باشند
|
||||
// if ($tour->status != 1) {
|
||||
// abort(404);
|
||||
// }
|
||||
//
|
||||
// // افزایش تعداد بازدید
|
||||
// $tour->increment('views_count');
|
||||
//
|
||||
// // بارگذاری اطلاعات مورد نیاز
|
||||
// $tour->load([
|
||||
// 'flights',
|
||||
// 'travelType',
|
||||
// ]);
|
||||
//
|
||||
// // تورهای مرتبط
|
||||
// $relatedTours = Tour::where('status', 1)
|
||||
// ->where('travel_type_id', $tour->travel_type_id)
|
||||
// ->where('id', '!=', $tour->id)
|
||||
// ->latest()
|
||||
// ->limit(4)
|
||||
// ->get();
|
||||
//
|
||||
// $isFav = false;
|
||||
//
|
||||
// if (auth()->check()) {
|
||||
// $isFav = Favorite::where('user_id', auth()->id())
|
||||
// ->where('favoritable_type', Tour::class)
|
||||
// ->where('favoritable_id', $tour->id)
|
||||
// ->exists();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// return view(
|
||||
// 'tours.show',
|
||||
// compact('tour', 'relatedTours', 'isFav')
|
||||
// );
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * جستجوی پیشنهادی
|
||||
// */
|
||||
// public function searchSuggestion(Request $request)
|
||||
// {
|
||||
// $q = $request->input('q', '');
|
||||
//
|
||||
// $tours = Tour::where('status', 1)
|
||||
// ->where(
|
||||
// 'title',
|
||||
// 'like',
|
||||
// '%' . $q . '%'
|
||||
// )
|
||||
// ->limit(8)
|
||||
// ->get([
|
||||
// 'id',
|
||||
// 'title',
|
||||
// 'slug',
|
||||
// 'price'
|
||||
// ]);
|
||||
//
|
||||
// return response()->json($tours);
|
||||
// }
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user