fix: fix flight list and make it dynamic
This commit is contained in:
@@ -8,14 +8,18 @@ use Illuminate\Http\Request;
|
||||
|
||||
class FlightController extends Controller
|
||||
{
|
||||
public function index()
|
||||
public function index(Request $request)
|
||||
{
|
||||
$flights =Flight::applySort()
|
||||
->where('status' , '=' , FlightStatus::AVAILABLE)
|
||||
->paginate()
|
||||
->withQueryString();
|
||||
$sort = $request->query('sort', 'default');
|
||||
|
||||
$flights = Flight::with(['airline', 'origin_airport', 'airport'])
|
||||
->where('status', '=', FlightStatus::AVAILABLE)
|
||||
->applySort($sort)
|
||||
->paginate(4)
|
||||
->appends(['sort' => $sort]);
|
||||
|
||||
$title = 'پروازها';
|
||||
return view('flights.index' , compact('title' , 'flights'));
|
||||
return view('flights.index', compact('title', 'flights', 'sort'));
|
||||
}
|
||||
|
||||
public function show(Flight $flight)
|
||||
|
||||
Reference in New Issue
Block a user