Files
hatame.andarza09/app/Http/Controllers/FlightController.php
T
hatame e72f68cd86 git add .
git commit "fix dashboard charts rendering and views data display"
2026-08-22 09:38:46 +03:30

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'));
}
}