feat: implement tour listing with sorting and pagination

This commit is contained in:
2026-08-17 16:37:11 +03:30
parent 5350cd1742
commit 9dc27863e2
8 changed files with 392 additions and 2 deletions
+36
View File
@@ -1,5 +1,8 @@
<?php
use App\Models\Tour;
use Carbon\Carbon;
if (!function_exists('generateSortRouteParameter')) {
function generateSortRouteParameter(string $sortKey): array
{
@@ -21,3 +24,36 @@ if (!function_exists('activeSort')) {
return 'text-gray-600 dark:text-gray-300 hover:text-blue-500';
}
}
if (!function_exists('tourDuration')) {
function tourDuration(Tour $tour): string
{
$departure = $tour->tourDepartures->first();
if (!$departure) {
return 'نامشخص';
}
$start = Carbon::parse($departure->start_date);
$end = Carbon::parse($departure->end_date);
$nights = $start->diffInDays($end);
$days = $nights + 1;
return "{$days} روز و {$nights} شب";
}
}
if (!function_exists('tourDateRange')) {
function tourDateRange(Tour $tour): string
{
$departure = $tour->tourDepartures->first();
if (!$departure) {
return 'تاریخ نامشخص';
}
$start = Verta::instance($departure->start_date);
$end = Verta::instance($departure->end_date);
return $start->format('Y/m/d') . ' - ' . $end->format('Y/m/d');
}
}