e72f68cd86
git commit "fix dashboard charts rendering and views data display"
40 lines
897 B
PHP
40 lines
897 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Tour;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class TourController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$newestTour = Tour::with('travelType')
|
|
->latest()
|
|
->paginate(3);
|
|
|
|
$tours = Tour::with('travelType')
|
|
->latest()
|
|
->paginate(2);
|
|
|
|
return view('tours.index', compact('tours'))
|
|
->with('withoutHero', true); }
|
|
|
|
|
|
public function show(Tour $tour)
|
|
{
|
|
$tour->load('travelType');
|
|
$tour->increment('views');
|
|
|
|
$cacheKey = 'tour_views:' . $tour->id . ':' . now()->format('Y-m-d');
|
|
Cache::put($cacheKey, Cache::get($cacheKey, 0) + 1, now()->addDays(15));
|
|
|
|
$comments = $tour->comments()
|
|
->latest()
|
|
->get();
|
|
|
|
|
|
return view('tours.show', compact('tour','comments'));
|
|
}
|
|
}
|