52 lines
956 B
PHP
52 lines
956 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Flight;
|
|
use App\Models\Tour;
|
|
use Illuminate\Http\Request;
|
|
|
|
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');
|
|
|
|
$comments = $flight->comments()
|
|
->latest()
|
|
->get();
|
|
|
|
|
|
return view('flights.show', compact('flight', 'comments'));
|
|
}
|
|
|
|
}
|