DEV Community

Cover image for Laravel 13.44: Form Request Model Lookups & PHP 8.6
devTalk
devTalk

Posted on Originally published at dev-talk.com

Laravel 13.44: Form Request Model Lookups & PHP 8.6

Last updated: 26 November 2026. Verified directly against the laravel/framework source for the v13.44.0/v13.44.1 tags; seeHow this was checked.

Laravel 13.44 ships two changes worth knowing about: form requests can now pull the Eloquent model behind their own input without you writing the lookup yourself, and the framework's test suite runs cleanly against PHP 8.6, which means two compatibility fixes landed that are worth knowing about even if you're nowhere near upgrading PHP yet.

Form requests can now fetch their own models

A new InteractsWithModels trait is mixed into the base FormRequest class, adding three methods: model(), modelOrFail(), and models(). The idea is simple: your form request already validated that product_id is an existing row, so it can hand you the actual Product instead of you querying for it again in the controller.

class UpdateProductRequest extends FormRequest
{
    public function rules(): array
    {
        return [
            'product_id' => ['required', 'exists:products,id'],
        ];
    }
}

// In the controller:
$product = $request->modelOrFail('product_id');
Enter fullscreen mode Exit fullscreen mode

By default the model class is guessed from the input key: product_id becomes Product, checked first against App\Models\Product and falling back to App\Product if that doesn't exist. The guessing strips a trailing _id or _ids and singularizes what's left, so a category_ids field guesses Category for the models() plural lookup. You're not stuck with the guess, though; pass the class explicitly when the input key doesn't match the model name:

$products = $request->models('ids', Product::class);

// Or scope the query with a closure:
$product = $request->model('product_id', Product::class, function ($query) {
    $query->where('store_id', $this->user()->store_id);
});
Enter fullscreen mode Exit fullscreen mode

model() returns null if the key is missing or empty, modelOrFail() throws ModelNotFoundException the same way route model binding does, and models() always returns a collection, empty if nothing matched. None of these replace validation, you still want exists:products,id in your rules so a bad ID fails with a normal validation error before it ever gets this far, but they remove the repeated "re-fetch what I already confirmed exists" boilerplate that shows up in a lot of update/destroy actions.

PHP 8.6 support, and what actually changed for it

Laravel 13.44 also moves PHP 8.6 out of the framework's experimental CI lane and runs it as a standard, non-experimental target alongside 8.3 through 8.5. composer.json's platform requirement stays at "php": "^8.3", so this isn't a version bump, it's confirmation that the framework's test suite passes cleanly under 8.6 without special-casing failures.

Two real compatibility fixes came with it, both narrow and both worth knowing if you hit strange behavior after upgrading your local PHP install ahead of your production environment:

  • Collection sorting by locale. Collection::sortByMany() previously used PHP's SORT_LOCALE_STRING flag with strcoll() for locale-aware string comparisons. On PHP 8.6, Laravel now detects the running version and, when it's 8.6 or later, uses Collator::create('')->compare() instead. If you sort collections by locale-aware string comparison, this is a drop-in behavior swap, not something you need to change in your own code.
  • A stricter internal numeric check in validation. Several numeric validation rules (gt, lt, gte, lte, numeric, and the internal size/comparison helpers) switched from calling PHP's built-in is_numeric() directly to a new protected isNumeric() helper on the validator. The helper excludes strings containing vertical tab or form feed characters that PHP 8.6 otherwise accepts as numeric whitespace. In practice, this keeps Laravel's numeric validation rules behaving the same across PHP 8.3 through 8.6, rather than suddenly accepting oddly-whitespaced strings as valid numbers once you upgrade PHP.

Neither fix requires any action on your part if you're using the built-in validation rules and collection sorting through Laravel's own APIs. They matter if you've copied is_numeric() checks into your own custom validation rules and want the same PHP 8.6 whitespace behavior Laravel now has internally.

update log

  • 26 November 2026: first version, covering v13.44.0 and v13.44.1.
  • To recheck next time: whether a future release changes composer.json's minimum PHP constraint to formally require 8.6, and whether guessModelClass()'s namespace-guessing logic changes.

Frequently asked questions

Do I need to validate a field before calling model() on it?

Yes. These methods look up whatever the input contains; they don't validate it. Keep an exists:table,column rule in your rules() method so a bad or missing ID fails validation with a normal error response before modelOrFail() would otherwise throw a less friendly exception.

What happens if the input key doesn't match my model name?

Pass the model class explicitly as the second argument: $request->model('owner_id', User::class). The automatic guessing only helps when the input key follows the usual thing_id / thing_ids convention.

Can I upgrade to PHP 8.6 in production now?

Laravel's own test suite now passes on it without the experimental flag, which is a good sign, but check your other dependencies' own PHP 8.6 compatibility before moving production workloads, since framework-level support doesn't guarantee every package in your composer.json has caught up yet.

Does the new Collator-based sorting change existing sort results?

Only on PHP 8.6, where it replaces a deprecated-leaning strcoll() path with Collator::compare(). On PHP 8.3 through 8.5, behavior is unchanged.

Related Dev Talk articles

Sources


Originally published on DEV Talk.

Top comments (0)