use Illuminate\Http\Request; $request = Request::capture(); $name = $request->input('name'); $age = $request->input('age', 0); // default value if 'age' is not present in input
use Illuminate\Http\Request; $request = Request::capture(); $file = $request->file('avatar'); if ($file->isValid()) { $file->move(public_path('avatars'), $file->getClientOriginalName()); return 'File uploaded successfully.'; }
use Illuminate\Http\Request; $request = Request::capture(); $userId = $request->cookie('user_id'); $token = $request->header('Authorization');This example shows how to retrieve values from cookies and HTTP headers that were sent with the request, using the `cookie()` and `header()` methods respectively. The `Illuminate\Http\Request` file is part of the `illuminate/http` package, which is a core part of the Laravel framework. This package provides the building blocks for handling HTTP requests and responses in a modular and extensible way, and is used throughout the Laravel ecosystem to power web applications and APIs.