Files
hatame.andarza09/app/Http/Controllers/TourController.php
T

36 lines
690 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Tour;
class TourController extends Controller
{
public function index()
{
$newestTour = Tour::with('travelType')
->latest()
->take(10)
->get();
$tours = Tour::with('travelType')
->latest()
->paginate(5);
return view('tours.index', compact('newestTour', 'tours'));
}
public function show(Tour $tour)
{
$tour->load('travelType');
$tour->increment('views');
$comments = $tour->comments()
->latest()
->get();
return view('tours.show', compact('tour','comments'));
}
}