
Laravel News · 3 min readPHP
Load Eloquent Models From Form Request Input in Laravel
Learn how Laravel 13.44’s FormRequest methods model(), modelOrFail(), and models() simplify loading Eloquent models from request input, reducing duplicate queries and centralizing team scoping logic. The guide shows step‑by‑step refactoring from manual validation to concise request‑side lookups, improving code clarity and security.
- Use modelOrFail('id', Model::class) to auto‑load a single model or throw an exception.
- Pass a closure to add team scoping: fn($q)=>$q->where('team_id',$this->user()->team_id).
- Wrap lookups in once() to cache results within a request and avoid duplicate queries.