feat: implement tour listing with sorting and pagination
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user