Complete the code to get the 'id' query parameter from the request.
$id = $request->[1]('id');
The query method retrieves query parameters from the URL in Laravel.
Complete the code to check if the 'page' query parameter exists in the request.
if ($request->[1]('page')) { // do something }
The has method checks if a query parameter is present in the request.
Fix the error in the code to get all query parameters as an array.
$params = $request->[1]();The query() method without arguments returns all query parameters as an array.
Fill both blanks to get the 'sort' query parameter with a default value of 'asc'.
$sort = $request->[1]('sort', [2]);
The query method can take a second argument as a default value if the parameter is missing.
Fill all three blanks to filter query parameters where values are not empty strings.
$filtered = collect($request->[1]())->filter(function($value) { return $value [2] ''; }); $filteredArray = $filtered->[3]();
We get all query parameters with query(), filter out empty strings using !==, and convert the collection back to array with toArray().