Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Add FormRequest::array($key) and Fluent::array($key) #54177

Merged
merged 3 commits into from
Jan 13, 2025

Conversation

stevebauman
Copy link
Contributor

@stevebauman stevebauman commented Jan 13, 2025

Description

This PR add an array($key) method to both the FormRequest and Fluent instance via the InteractsWithDataTrait.

Previously, to retrieve a value from either instance as an array you had to manually cast the result yourself:

$fluent = new Fluent(['...']);

(array) $fluent->get('value');

Or use ->collect()->all():

public function store(UserRequest $request)
{
    $values = $request->collect('...')->all();

    // ...
}

Usage

This allows developers to always retrieve a value as an array:

$fluent = new Fluent(['...']);

$values = $fluent->array('value');
public function store(UserRequest $request)
{
    $values = $request->array('...');

    // ...
}

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@taylorotwell taylorotwell merged commit 2af2e0d into laravel:11.x Jan 13, 2025
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants