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

[5.5] Add a "validated" method to the form request #19112

Merged
merged 2 commits into from
May 12, 2017

Conversation

JosephSilber
Copy link
Member

@JosephSilber JosephSilber commented May 9, 2017

Would allow you to only get the validated input from the request:

public function store(MySpecialSnowflakeRequest $request)
{
    return Zonda::create($request->validated());
}

@JosephSilber JosephSilber force-pushed the form-request-validated branch from 92e5e25 to 86beb6b Compare May 9, 2017 00:54
@JosephSilber JosephSilber force-pushed the form-request-validated branch from 86beb6b to e9a28ac Compare May 9, 2017 01:10
@taylorotwell
Copy link
Member

Can we name the method validated? Does that conflict with anything?

@JosephSilber JosephSilber force-pushed the form-request-validated branch from e9a28ac to 81f3426 Compare May 9, 2017 13:25
@JosephSilber JosephSilber changed the title [5.5] Add a "validInput" method to the form request [5.5] Add a "validated" method to the form request May 9, 2017
@JosephSilber JosephSilber force-pushed the form-request-validated branch from 81f3426 to eb02670 Compare May 9, 2017 13:30
*/
public function validated()
{
return $this->only(array_keys($this->container->call([$this, 'rules'])));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JosephSilber why not calling $this->rules() directly as the object is already instantiated?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rodrigopedra $this->container->call([$this, 'rules']) calls the method and inject any dependencies it has declared, as method parantheses. $this->rules() doesn't.

@taylorotwell taylorotwell merged commit eb02670 into laravel:master May 12, 2017
@JosephSilber JosephSilber deleted the form-request-validated branch May 12, 2017 15:04
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.

4 participants