feat: implement flight sorting and pagination
This commit is contained in:
@@ -10,15 +10,19 @@ class FlightController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$sort = $request->query('sort', 'default');
|
||||
|
||||
$flights = Flight::with(['airline', 'origin_airport', 'airport'])
|
||||
->where('status', '=', FlightStatus::AVAILABLE)
|
||||
$sort = $request->query('sort', 'default');
|
||||
$title = 'پروازها';
|
||||
|
||||
$flights = Flight::with(['airline', 'origin_airport.city', 'airport.city'])
|
||||
->where('status', FlightStatus::AVAILABLE)
|
||||
->filterFrom($request->input('from-destination'))
|
||||
->filterTo($request->input('to-destination'))
|
||||
->filterDepartureDate($request->input('journey-date'))
|
||||
->applySort($sort)
|
||||
->paginate(4)
|
||||
->appends(['sort' => $sort]);
|
||||
->withQueryString();
|
||||
|
||||
$title = 'پروازها';
|
||||
return view('flights.index', compact('title', 'flights', 'sort'));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user