Skip to content

Commit

Permalink
formatting and method naming
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed May 19, 2021
1 parent 3baf475 commit 498e1a0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,19 @@ public function ofMany($column = 'id', $aggregate = 'MAX', $relation = null)
throw new InvalidArgumentException("Invalid aggregate [{$aggregate}] used within ofMany relation. Available aggregates: MIN, MAX");
}

$subQuery = $this->newSubQuery(
$subQuery = $this->newOneOfManySubQuery(
isset($previous) ? $previous['column'] : $this->getOneOfManySubQuerySelectColumns(),
$column, $aggregate
);

if (isset($previous)) {
$this->addJoinSub($subQuery, $previous['subQuery'], $previous['column']);
$this->addOneOfManyJoinSubQuery($subQuery, $previous['subQuery'], $previous['column']);
} elseif (isset($closure)) {
$closure($subQuery);
}

if (array_key_last($columns) == $column) {
$this->addJoinSub($this->query, $subQuery, $column);
$this->addOneOfManyJoinSubQuery($this->query, $subQuery, $column);
}

$previous = [
Expand Down Expand Up @@ -148,7 +148,7 @@ public function oldestOfMany($column = 'id', $relation = null)
* @param string|null $aggregate
* @return \Illuminate\Database\Eloquent\Builder
*/
protected function newSubQuery($groupBy, $column = null, $aggregate = null)
protected function newOneOfManySubQuery($groupBy, $column = null, $aggregate = null)
{
$subQuery = $this->query->getModel()
->newQuery();
Expand All @@ -174,7 +174,7 @@ protected function newSubQuery($groupBy, $column = null, $aggregate = null)
* @param string $on
* @return void
*/
protected function addJoinSub(Builder $parent, Builder $subQuery, $on)
protected function addOneOfManyJoinSubQuery(Builder $parent, Builder $subQuery, $on)
{
$parent->joinSub($subQuery, $this->relationName, function ($join) use ($on) {
$join->on($this->qualifySubSelectColumn($on), '=', $this->qualifyRelatedColumn($on));
Expand All @@ -184,12 +184,12 @@ protected function addJoinSub(Builder $parent, Builder $subQuery, $on)
}

/**
* Merge relation ship query joins to the given query builder.
* Merge the relationship query joins to the given query builder.
*
* @param \Illuminate\Database\Eloquent\Builder $builder
* @return void
*/
protected function mergeJoinsTo(Builder $query)
protected function mergeOneOfManyJoinsTo(Builder $query)
{
$query->getQuery()->joins = $this->query->getQuery()->joins;

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Relations/HasOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function match(array $models, Collection $results, $relation)
public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*'])
{
if ($this->isOneOfMany()) {
$this->mergeJoinsTo($query);
$this->mergeOneOfManyJoinsTo($query);
}

return parent::getRelationExistenceQuery($query, $parentQuery, $columns);
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Relations/MorphOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function match(array $models, Collection $results, $relation)
public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*'])
{
if ($this->isOneOfMany()) {
$this->mergeJoinsTo($query);
$this->mergeOneOfManyJoinsTo($query);
}

return parent::getRelationExistenceQuery($query, $parentQuery, $columns);
Expand Down

0 comments on commit 498e1a0

Please sign in to comment.