Laravel Castable Request
Last updated
Was this helpful?
Last updated
Was this helpful?
This package applies eloquent model casts to the request input.
Implement Lionix\CastableRequest\Contracts\CastableRequestInterface
in your Request class. You will have to declare casts
method that will return the attributes that should be casted just like you would do it with .
The package will do all the magic and when you access the request created_after
attribute, in this case, it will be casted to an Illuminate\Support\Carbon
instance.
All default eloquent models castings are available.
If you want to declare casts that will be applied globally without having to define it in each Request class you can use the Lionix\CastableRequest\Contracts\CastsRegistryInterface
in your service provider and register global casts.
Add global request casts support for facades and request
helper.
Starting from the Laravel 7.x you can define your own and use it in the request as well.