Skip to content

Commit

Permalink
fix(laravel): use Model::qualifyColumn instead of hardcoding $table.$…
Browse files Browse the repository at this point in the history
…column (#6658)
  • Loading branch information
GromNaN authored Sep 23, 2024
1 parent 85306f2 commit a6e3706
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Laravel/Eloquent/State/LinksHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ public function handleLinks(Builder $builder, array $uriVariables, array $contex
$identifier = $uriVariables[$uriVariable];

if ($to = $link->getToProperty()) {
$builder = $builder->where($builder->getModel()->getTable().'.'.$builder->getModel()->{$to}()->getForeignKeyName(), $identifier);
$builder = $builder->where($builder->getModel()->{$to}()->getQualifiedForeignKeyName(), $identifier);

continue;
}

if ($from = $link->getFromProperty()) {
$relation = $this->application->make($link->getFromClass());
$builder = $builder->getModel()->where($builder->getModel()->getTable().'.'.$relation->{$from}()->getForeignKeyName(), $identifier);
$builder = $builder->getModel()->where($relation->{$from}()->getQualifiedForeignKeyName(), $identifier);

continue;
}

$builder->where($builder->getModel()->getTable().'.'.$link->getIdentifiers()[0], $identifier);
$builder->where($builder->getModel()->qualifyColumn($link->getIdentifiers()[0]), $identifier);
}

return $builder;
Expand Down

0 comments on commit a6e3706

Please sign in to comment.