Skip to content

Conversation

@nicDamours
Copy link
Contributor

@nicDamours nicDamours commented Aug 1, 2025

When calling the hasNested function with a string of relationship of which the first one was a morphTo, we had a Error: Call to a member function getRelationExistenceQuery() on null.

This is because the $relations array, in the hasNested function is passed by reference, but not reset between morph types.

The proposed solution is not perfect, but it works fine. I'm open to suggestion as I'm sure it can be a little bit more elegant.

Fixes #56490

Fixed an issue with hasNested fn when the first relation is a morphTo relationship. The `$relation` array was not reset, so we were calling the `has` with a null relation.
@nicDamours nicDamours changed the title Fixed Fixed the issue when calling hasNested with a first relationship of type morphTo. Aug 1, 2025
Nicolas D'Amours added 2 commits August 1, 2025 11:14
Fixed formatting issue from style-ci.
Fixed formatting issue from style-ci.
@nicDamours nicDamours changed the title Fixed the issue when calling hasNested with a first relationship of type morphTo. [12.x] Fixed the issue when calling hasNested with a first relationship of type morphTo. Aug 1, 2025
@nicDamours nicDamours changed the title [12.x] Fixed the issue when calling hasNested with a first relationship of type morphTo. [12.x] Fixed an issue when calling hasNested with a first relationship of type morphTo. Aug 1, 2025
@taylorotwell taylorotwell merged commit bb5dfb5 into laravel:12.x Aug 6, 2025
60 checks passed
macropay-solutions pushed a commit to macropay-solutions/maravel-framework that referenced this pull request Aug 6, 2025
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.

Unable to use hasNested with morphTo relationship

2 participants