e72f68cd86
git commit "fix dashboard charts rendering and views data display"
56 lines
1.1 KiB
PHP
56 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Flight;
|
|
use App\Models\Tour;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class FlightController extends Controller
|
|
{
|
|
public function index(Request $request)
|
|
{
|
|
$flights = Flight::latest()
|
|
->applySearch($request->all())
|
|
->paginate(10);
|
|
|
|
|
|
$newestFlight = Flight::latest()
|
|
->take(3)
|
|
->get();
|
|
|
|
|
|
$newestTour = Tour::latest()
|
|
->take(3)
|
|
->get();
|
|
|
|
|
|
$tours = Tour::latest()
|
|
->paginate(10);
|
|
|
|
|
|
return view('flights.index', compact(
|
|
'flights',
|
|
'newestFlight',
|
|
'newestTour',
|
|
'tours'
|
|
));
|
|
}
|
|
public function show(Flight $flight)
|
|
{
|
|
$flight->increment('views');
|
|
|
|
$cacheKey = 'flight_views:' . $flight->id . ':' . now()->format('Y-m-d');
|
|
Cache::put($cacheKey, Cache::get($cacheKey, 0) + 1, now()->addDays(15));
|
|
|
|
$comments = $flight->comments()
|
|
->latest()
|
|
->get();
|
|
|
|
|
|
return view('flights.show', compact('flight', 'comments'));
|
|
}
|
|
|
|
}
|