Laravel 13.44 adds Eloquent model lookups to form requests

Three helpers let Laravel applications resolve one or more Eloquent models from request input and optionally scope the lookup query.

Laravel 13.44 adds Eloquent model lookups to form requests

Laravel 13.44.0, released on November 25, added three form request helpers for turning record identifiers in request input into Eloquent models. The change gives applications a shared way to express lookups that previously required explicit queries.

How the three helpers differ

model() resolves one record and can return null. modelOrFail() raises a model-not-found exception when the record is missing. models() returns a collection. Developers can specify a model class explicitly or use Laravel’s convention for inferring it from the input key.

Where query scoping fits

Applications can narrow a lookup to records appropriate for the request. Input validation and authorization remain separate parts of deciding whether the caller may use the record.

Sources: Laravel News feature guide, its release coverage and the Laravel newsletter.

Share

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0