feat(tours): add tour listing with pagination and routers

This commit is contained in:
2026-08-17 13:04:11 +03:30
parent 71b11b70e4
commit 1508654176
6 changed files with 118 additions and 2 deletions
+17
View File
@@ -3,10 +3,27 @@
namespace App\Http\Controllers;
use App\Models\Tour;
use Carbon\Carbon;
use Illuminate\Http\Request;
class TourController extends Controller
{
public function index()
{
$tours = Tour::with('tour_details')->latest()->paginate(6);
$tours->each(function ($tour) {
$detail = $tour->tour_details->first();
$tour->nights = $detail
? Carbon::parse($detail->start_date)->diffInDays(Carbon::parse($detail->end_date))
: null;
});
return view('tours.index', compact('tours'));
}
public function show(Tour $tour)
{
$tour->load([
+5 -1
View File
@@ -33,7 +33,11 @@ use Illuminate\Database\Eloquent\Model;
*/
class Tour extends Model
{
protected $table = 'tours';
/**
* @var float|mixed|null
*/
public mixed $nights;
protected $table = 'tours';
protected $casts = [
'file_id' => 'int',
+3 -1
View File
@@ -3,6 +3,7 @@
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Pagination\Paginator;
class AppServiceProvider extends ServiceProvider
{
@@ -19,6 +20,7 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot(): void
{
//
Paginator::useBootstrapFive();
}
}