Requests
Request provides input, headers, files, and authenticated identity.
What it is
Request provides input, headers, files, and authenticated identity.
When to use it
Read request data at the HTTP boundary.
Syntax
$request->input("name");
$request->user();
$request->header("Idempotency-Key");Example
public function index(Request $request)
{
$data = $request->validate(["limit" => "sometimes|integer|min:1|max:100"]);
return Order::where("user_id", $request->user()->id)
->paginate($data["limit"] ?? 20);
}Common mistakes
Do not trust request user_id for ownership; use the authenticated user.