Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

franciscocaldeira's avatar

Retrieving An Input Value vs Retrieving Input Via Dynamic Properties

Hey guys, Retrieving Input Via Dynamic Properties will "first look for the parameter's value in the request payload. If it is not present, Laravel will search for the field in the matched route's parameters". For Retrieving An Input Value I saw "While the input method retrieves values from the entire request payload (including the query string)" I don't understand well this, can someone explain

0 likes
2 replies
tykus's avatar

First, dynamic property because you can retrieve an input value using $request->input('email'), or $request->email.

A dynamic property is not a public property that is defined on the Request class, instead in PHP, we can implement a magic __get method on the class which responds to messages for protected, private or non-existing instance properties.

The Illuminate Request class has this implementation, which attempts to retrieve the value for a given $key from the payload (inputs) array (returned by all()), or fallback to the Route wildcard segment:

    /**
     * Get an input element from the request.
     *
     * @param  string  $key
     * @return mixed
     */
    public function __get($key)
    {
        return Arr::get($this->all(), $key, fn () => $this->route($key));
    }
franciscocaldeira's avatar

@tykus Retrieving An Input Value is going to search on payload first and then if not present go to query string? (the opposite of Retrieving Input Via Dynamic)

Please or to participate in this conversation.