laralgato / request-object
Simple way to convert your request data to an object.
1.0.0
2025-07-10 17:38 UTC
Requires
- php: ^8.2
This package is not auto-updated.
Last update: 2025-07-10 17:41:24 UTC
README
Simple way to convert your request data to an object.
Installation
Install via Composer:
composer require laralgato/request-object
Usage
After installing the package, you can simply add a trait and an attribute to your Request. The Attribute accepts the object that you want as a result of the toObject method.
use Laragato\RequestObject\Attributes\FormObject; use Laragato\RequestObject\Traits\useObjectRequest; #[FormObject(MyObject::class)] class TestRequest extends FormRequest { use useObjectRequest; ... }
In your controller you can simply use:
class TestController extends Controller { public function __invoke(TestRequest $request) { $request->toObject(); } }
This line will perform the validation and return the object giving in the request.
Enjoy :)