Skip to content

[13.x] Fix Eloquent Collection duplicates() with a key or callback - #61597

Merged
taylorotwell merged 1 commit into
laravel:13.xfrom
lazerg:fix/issue-61595-duplicates
Sep 16, 2026
Merged

taylorotwell merged 1 commit into
laravel:13.xfrom
lazerg:fix/issue-61595-duplicates

Conversation

@lazerg

@lazerg lazerg commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Fixes #61595

When duplicates() or duplicatesStrict() is called on an Eloquent Collection with a key or callback, the collection maps the items to scalar values but still uses the model is() comparator, resulting in a fatal error. This PR forwards those calls to the base collection so the scalar duplicates are handled correctly.

@taylorotwell
taylorotwell merged commit 2c4f1c1 into laravel:13.x Sep 16, 2026
56 checks passed
binaryfire added a commit to hypervel/components-backup that referenced this pull request Oct 1, 2026
Handle string outer keys in collapseWithKeys and describe receiver types after collection mutation, including nullable keys. Return base collections for Eloquent duplicate attribute or callback values; keep model collections when no callback is supplied.

Correct mapped duplicate and sum types, annotate empty builders and Wayfinder defaults, and preserve explicit null-key behavior without PHP 8.5 deprecations. Consolidate overlapping coverage. Collection tests and full type analysis pass.

Upstream:
laravel/framework#61539
laravel/framework#61571
laravel/framework#61572
laravel/framework#61578
laravel/framework#61597
laravel/framework#61611
laravel/framework#61621

Source: laravel/framework at 7068848dfe48fc3a433598e09ce798799d442a52.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Illuminate\Database\Eloquent\Collection duplicates() doesn't work like Illuminate\Support\Collection

2 participants