You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[7.x] Fix regressions on find* methods with Arrayable ids (#30312)
* Ensure Builder::findOrFail with Arrayable throws ModelNotFoundException
I found a regression in #7048 and #19019, where the Eloquent Builder will not throw a `ModelNotFoundException` when an `Arrayable` is passed to `findOrFail`.
In this #7048, we are checking if the `$ids` is an array and we count the results against the number of ids.
But since #19019, the `find` method also accepts an `Arrayable` for the ids.
So if an `Arrayable` is passed, the check is skipped and the method returns the results.
To fix this, we are first checking if the `$ids` is an `Arrayable` and we convert the ids to an array before checking the results.
* Ensure find* methods on relationships are accepting Arrayable idsThe regression in #7048 and #19019 is also observed in #9143, because the `find`, `findMany` and `findOrFail` methods are copied from the Eloquent Builder to the `BelongsToMany` and `HasManyThrough` relations.For this reason, we need to convert the passed ids to an array before executing the queries.
0 commit comments