forked from devsam/core
dep: package update
This commit is contained in:
@@ -277,7 +277,7 @@ class BelongsToMany extends Relation
|
||||
|
||||
// Once we have an array dictionary of child objects we can easily match the
|
||||
// children back to their parent using the dictionary and the keys on the
|
||||
// the parent models. Then we will return the hydrated models back out.
|
||||
// parent models. Then we should return these hydrated models back out.
|
||||
foreach ($models as $model) {
|
||||
$key = $this->getDictionaryKey($model->{$this->parentKey});
|
||||
|
||||
|
||||
@@ -102,7 +102,9 @@ trait CanBeOneOfMany
|
||||
|
||||
if (isset($previous)) {
|
||||
$this->addOneOfManyJoinSubQuery($subQuery, $previous['subQuery'], $previous['column']);
|
||||
} elseif (isset($closure)) {
|
||||
}
|
||||
|
||||
if (isset($closure)) {
|
||||
$closure($subQuery);
|
||||
}
|
||||
|
||||
@@ -122,6 +124,12 @@ trait CanBeOneOfMany
|
||||
|
||||
$this->addConstraints();
|
||||
|
||||
$columns = $this->query->getQuery()->columns;
|
||||
|
||||
if (is_null($columns) || $columns === ['*']) {
|
||||
$this->select([$this->qualifyColumn('*')]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -137,7 +145,7 @@ trait CanBeOneOfMany
|
||||
{
|
||||
return $this->ofMany(collect(Arr::wrap($column))->mapWithKeys(function ($column) {
|
||||
return [$column => 'MAX'];
|
||||
})->all(), 'MAX', $relation ?: $this->guessRelationship());
|
||||
})->all(), 'MAX', $relation);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,7 +160,7 @@ trait CanBeOneOfMany
|
||||
{
|
||||
return $this->ofMany(collect(Arr::wrap($column))->mapWithKeys(function ($column) {
|
||||
return [$column => 'MIN'];
|
||||
})->all(), 'MIN', $relation ?: $this->guessRelationship());
|
||||
})->all(), 'MIN', $relation);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,14 +187,15 @@ trait CanBeOneOfMany
|
||||
protected function newOneOfManySubQuery($groupBy, $column = null, $aggregate = null)
|
||||
{
|
||||
$subQuery = $this->query->getModel()
|
||||
->newQuery();
|
||||
->newQuery()
|
||||
->withoutGlobalScopes($this->removedScopes());
|
||||
|
||||
foreach (Arr::wrap($groupBy) as $group) {
|
||||
$subQuery->groupBy($this->qualifyRelatedColumn($group));
|
||||
}
|
||||
|
||||
if (! is_null($column)) {
|
||||
$subQuery->selectRaw($aggregate.'('.$subQuery->getQuery()->grammar->wrap($column).') as '.$subQuery->getQuery()->grammar->wrap($column));
|
||||
$subQuery->selectRaw($aggregate.'('.$subQuery->getQuery()->grammar->wrap($subQuery->qualifyColumn($column)).') as '.$subQuery->getQuery()->grammar->wrap($column.'_aggregate'));
|
||||
}
|
||||
|
||||
$this->addOneOfManySubQueryConstraints($subQuery, $groupBy, $column, $aggregate);
|
||||
@@ -208,7 +217,7 @@ trait CanBeOneOfMany
|
||||
$subQuery->applyBeforeQueryCallbacks();
|
||||
|
||||
$parent->joinSub($subQuery, $this->relationName, function ($join) use ($on) {
|
||||
$join->on($this->qualifySubSelectColumn($on), '=', $this->qualifyRelatedColumn($on));
|
||||
$join->on($this->qualifySubSelectColumn($on.'_aggregate'), '=', $this->qualifyRelatedColumn($on));
|
||||
|
||||
$this->addOneOfManyJoinSubQueryConstraints($join, $on);
|
||||
});
|
||||
|
||||
@@ -407,7 +407,7 @@ abstract class Relation
|
||||
/**
|
||||
* Define the morph map for polymorphic relations and require all morphed models to be explicitly mapped.
|
||||
*
|
||||
* @param array|null $map
|
||||
* @param array $map
|
||||
* @param bool $merge
|
||||
* @return array
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user