Form Request Validation Tips for Cleaner Controllers
Form Requests do more than validate. These tips cover authorization, data prep, after hooks, and returning clean validated data your controllers will love.
If your controllers are still calling $request->validate([...]) inline, you are leaving a lot of Laravel's best validation features on the table. Form Requests move validation, authorization, and input preparation out of the controller and into a single dedicated class. Here is how to use them well. Return Only Validated Data The single most useful habit: never pull raw input into your create and update calls. Use validated() so only the fields that passed validation reach your model: public function store(StorePostRequest $request) { // Only validated keys — no mass-assignment surprises $post = Post::create($request->validated()); return redirect()->route('posts.show', $post); } Need a subset? safe() gives you only() and except(): $data = $request->safe()->only(['title', 'body']); $data = $request->safe()->except(['published_at']); Put Authorization Where It Belongs The authorize() method runs before validation. Use it to keep permission checks out of the controller entirely: public f...
Form Requests do more than validate. These tips cover authorization, data prep, after hooks, and returning clean validated data your controllers will love.
A step-by-step guide to handling file uploads in Laravel and storing them on Amazon S3, including validation, private files, and temporary signed URLs.
Blade components are more powerful than most developers realize. These tricks cover attribute bags, named slots, props, and conditional rendering you will use daily.
Laravel 13.16.0 lands with a built-in artisan dev command, a smarter queue worker, and a foreignUuidFor migration helper. Here is what changed and why it matters.
Most foreach loops in a Laravel app can be replaced with a single, more readable collection method. Here are seven that will clean up your code today.
Laravel's event system is one of its most powerful architectural tools. This lesson explains events, listeners, queued listeners, event subscribers, and observers, and when to reach for each.
Laravel Scout makes adding full-text search to your app surprisingly straightforward. This tutorial covers installation, indexing, searching, filtering, and deploying with Meilisearch.
Laravel Cloud just shipped Scale-to-Zero Flex compute, 20x faster cold starts, and a new four-tier pricing structure. Here is what changed and what it means for your hosting bill.
Pest PHP makes Laravel testing more expressive and less boilerplate-heavy. This tutorial walks through installation, expectations, datasets, higher-order tests, and architecture rules.