36 lines
682 B
PHP
36 lines
682 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Flight;
|
|
use Illuminate\Http\Request;
|
|
|
|
class FlightController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$newestFlight = Flight::
|
|
latest()
|
|
->applySearch()
|
|
->take(10)
|
|
->get();
|
|
$flights = Flight::latest()->
|
|
paginate(9);
|
|
|
|
return view('home.index', compact('newestFlight', 'flights'));
|
|
}
|
|
|
|
public function show(Flight $flight)
|
|
{
|
|
$flight->increment('views');
|
|
|
|
$comments = $flight->comments()
|
|
->latest()
|
|
->get();
|
|
|
|
|
|
return view('flights.show', compact('flight','comments'));
|
|
}
|
|
|
|
}
|