Skip to content

Conversation

@imliam
Copy link
Contributor

@imliam imliam commented Oct 4, 2025

- $team->user_id === $user->id;
+ $team->user()->is($user);

Comment on lines +57 to +59
if (! $node instanceof Equal && ! $node instanceof Identical) {
return null;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a redundant check, since we're always passing Equal or Identical.

Comment on lines +116 to +124
private function isForeignKeyToIdPattern(string $leftProperty, string $rightProperty): bool
{
return str_ends_with($leftProperty, '_id') && $rightProperty === 'id';
}

private function extractRelationshipName(string $foreignKeyProperty): string
{
return substr($foreignKeyProperty, 0, -3);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid this part here won't work well with a lot of cases.

It assumes that the key is always 'id' or follows the standard '_id'. I'm not sure if we can find the key name from the model's getKeyName() method or the $primaryKey property.

Also, it fails when relationship names are complex (nationalTeam() with national_team_id key), or don't exist (external_team_id, but no externalTeam() relationship).

The only way this could work well would be to check the relationships.

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.

2 participants