The functionality provided by this is now baked directly into Laravel 5.5+ thanks the Joseph Silber. You should use that 👍
A trait you can utilise in your Laravel form request objects to ensure the data you are accessing from the request has been validated.
Why? See my post: Enforcing Valid Data Access From a Form Request Object.
You can install using composer from Packagist.
composer require timacdonald/laravel-access-validated-inputs
This package uses Semantic Versioning. You can find out more about what this is and why it matters by reading the spec or for something more readable, check out this post.
First you need to use the trait in your form request object:
class PostFormRequest extends FormRequest
Then in your controller you may call:
class PostController extends Controller
public function store(PostFormRequest $form)
Please feel free to suggest new ideas or send through pull requests to make this better. If you'd like to discuss the project, feel free to reach out on Twitter.
I've been thinking this could be awesome if it actually removed all the unvalidated inputs automatically so that all the Request's native methods only, intersect etc return validated inputs.
This package is under the MIT License. See LICENSE file for details.