Known limitations
- Laravel 12 with MySQL or PostgreSQL: filters and relation or aggregate sorts through a
hasOneThroughrelation defined withofMany()fail in Eloquent itself. Laravel 13 fixes it. - PostgreSQL and mixed morph ids: PostgreSQL does not compare columns of different types. When a
morphTostores the ids of several types in one string column (uuids and integers), filters and sorts through it cast the id for every type keyed by an integer or a nativeuuidprimary key; for a string key the column type is read from the schema once per table and request. Aggregate includes under such a type (withCountof Eloquent itself) fail. - Filters and sorts through a morphTo do not check that every listed type has the column; a missing column is an SQL error. The macros of a
constrain()callback on themorphToare not replayed in them.onlyIncluded()through amorphToincluded by a plain string (notRelationship::morphTo()) without a morph map leaves the models the filter does not list as they are, instead of loading none of them. - A root table alias: when
query()selects from an alias (User::query()->from('users as u')), the constraint of a relation filter or sort is rewritten to the alias as a whole: a join of your own on the root table inside it refers to the alias too. On Laravel 12, filters and sorts through a relation to a model withSoftDeletesfail under such an alias in Eloquent itself. - PostgreSQL and string morph ids: a
morphMany/morphOnewhose id column is a string (it holds uuids and integers) cannot be loaded, filtered or counted from a model with an integer key in Eloquent itself (character varying = integer).