lorisleiva / laravel-actions

⚡️ Laravel components that take care of one specific task
https://laravelactions.com
MIT License
2.52k stars 124 forks source link

Implement option to get a validated input using key #213

Closed istiak-tridip closed 1 year ago

istiak-tridip commented 2 years ago

Although the ActionRequest::validated method accepts the $key and $default parameters (for FormRequest compatibility), these parameters are not used as implemented in Laravel (#36807).

This PR fixes that.

Previous Behavior:

public function handle(ActionRequest $request) {
    $validated = $request->validated(); // Returns an array

    $password = $request->validated('password'); // Still returns an array
}

New Behavior:

public function handle(ActionRequest $request) {
    $validated = $request->validated(); // Returns an array

    $password = $request->validated('password'); // Still returns the validated `password` field's value
}
lorisleiva commented 1 year ago

That's a very good point. Thanks for your contribution! 🍺