[11.x] Add Request::fluent method#53662
Conversation
|
Nice 👌 what're your thoughts on a FluentRequest class that can be used to type hint the controller function param to allow auto-injection of the fluent wrapped version, avoiding need for the manual call to ->fluent()? Easy enough to write in userland I guess, but a nicety I'd probably never get round to in my projects. |
|
@GavG I'm not sure if that'd be easily do-able, and/or worth the pay-off, imo. How would it work? |
Having had a look through, I'd agree, it's not worth the pay off. It could be done when resolving controller method params, but it wouldn't be especially clean. Users who wanted to could, I think, use a custom contextual cast. So I retract my idea, for the sake of saving one line of code 😂 |
|
@GavG haha okay sounds good! Appreciate the discussion though. |
Description
This PR adds a new
fluent()method to theIlluminate\Http\Requestclass.Similar to the
Request::collectmethod, being able to transform the request input to aFluentinstance helps in being able to transport the input data around your application (such as an action or a queued job) and provides you null-safe access instead of using an array.Usage
Consider an action that consumes a
Fluentinstance to access request data safely that may be nullable, while also being portable for easy testing without having to provide a request instance: