@@ -40,7 +40,7 @@ |
||
| 40 | 40 | */ |
| 41 | 41 | protected function buildDictionary(Collection $results) |
| 42 | 42 | { |
| 43 | - return $results->mapToDictionary(function (Model $result) { |
|
| 43 | + return $results->mapToDictionary(function(Model $result) { |
|
| 44 | 44 | return [$result->getFirstPathSegment() => $result]; |
| 45 | 45 | })->all(); |
| 46 | 46 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | public function addConstraints() |
| 22 | 22 | { |
| 23 | 23 | if (static::$constraints) { |
| 24 | - $constraint = function (Builder $query) { |
|
| 24 | + $constraint = function(Builder $query) { |
|
| 25 | 25 | if ($this->andSelf) { |
| 26 | 26 | $query->where($this->getQualifiedLocalKeyName(), '=', $this->getParentKey()); |
| 27 | 27 | } else { |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $keys = $this->getKeys($models, $this->localKey); |
| 50 | 50 | |
| 51 | - $constraint = function (Builder $query) use ($models, $whereIn, $column, $keys) { |
|
| 51 | + $constraint = function(Builder $query) use ($models, $whereIn, $column, $keys) { |
|
| 52 | 52 | $query->$whereIn($column, $keys); |
| 53 | 53 | }; |
| 54 | 54 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | $foreignKey = $this->getForeignKeyName(); |
| 98 | 98 | |
| 99 | - return $results->mapToDictionary(function (Model $result) use ($dictionary, $foreignKey) { |
|
| 99 | + return $results->mapToDictionary(function(Model $result) use ($dictionary, $foreignKey) { |
|
| 100 | 100 | if ($result->hasNestedPath()) { |
| 101 | 101 | $key = $dictionary[$result->getFirstPathSegment()]->{$foreignKey}; |
| 102 | 102 | } else { |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | ? $query->getQuery()->from.'.'.$this->localKey |
| 126 | 126 | : $this->foreignKey; |
| 127 | 127 | |
| 128 | - $constraint = function (Builder $query) use ($first) { |
|
| 128 | + $constraint = function(Builder $query) use ($first) { |
|
| 129 | 129 | $query->whereColumn( |
| 130 | 130 | $first, |
| 131 | 131 | '=', |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | ? $table.'.'.$this->localKey |
| 157 | 157 | : $table.'.'.$this->getForeignKeyName(); |
| 158 | 158 | |
| 159 | - $constraint = function (Builder $query) use ($first) { |
|
| 159 | + $constraint = function(Builder $query) use ($first) { |
|
| 160 | 160 | $query->whereColumn( |
| 161 | 161 | $first, |
| 162 | 162 | '=', |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $value = $this->related->newCollection($dictionary[$key]); |
| 94 | 94 | |
| 95 | 95 | if (!$this->andSelf) { |
| 96 | - $value = $value->reject(function (Model $result) use ($model) { |
|
| 96 | + $value = $value->reject(function(Model $result) use ($model) { |
|
| 97 | 97 | return $result->{$result->getLocalKeyName()} == $model->{$model->getLocalKeyName()}; |
| 98 | 98 | })->values(); |
| 99 | 99 | } |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | $second = $parentQuery->qualifyColumn($this->localKey); |
| 134 | 134 | |
| 135 | 135 | $query->select($columns) |
| 136 | - ->where(function (Builder $query) use ($first, $second) { |
|
| 136 | + ->where(function(Builder $query) use ($first, $second) { |
|
| 137 | 137 | $query->whereColumn($first, '=', $second) |
| 138 | - ->orWhere(function (Builder $query) use ($first, $second) { |
|
| 138 | + ->orWhere(function(Builder $query) use ($first, $second) { |
|
| 139 | 139 | $query->whereNull($first)->whereNull($second); |
| 140 | 140 | }); |
| 141 | 141 | }); |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | $second = $this->getQualifiedParentKeyName(); |
| 172 | 172 | |
| 173 | 173 | $query->select($columns) |
| 174 | - ->where(function (Builder $query) use ($first, $second) { |
|
| 174 | + ->where(function(Builder $query) use ($first, $second) { |
|
| 175 | 175 | $query->whereColumn($first, '=', $second) |
| 176 | - ->orWhere(function (Builder $query) use ($first, $second) { |
|
| 176 | + ->orWhere(function(Builder $query) use ($first, $second) { |
|
| 177 | 177 | $query->whereNull($first)->whereNull($second); |
| 178 | 178 | }); |
| 179 | 179 | }); |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | public function addConstraints() |
| 19 | 19 | { |
| 20 | 20 | if (static::$constraints) { |
| 21 | - $constraint = function (Builder $query) { |
|
| 21 | + $constraint = function(Builder $query) { |
|
| 22 | 22 | $key = $this->andSelf ? $this->getParentKey() : $this->getForeignKey(); |
| 23 | 23 | |
| 24 | 24 | $query->where($this->getQualifiedLocalKeyName(), '=', $key); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $keys = $this->getKeys($models, $key); |
| 44 | 44 | |
| 45 | - $constraint = function (Builder $query) use ($whereIn, $keys) { |
|
| 45 | + $constraint = function(Builder $query) use ($whereIn, $keys) { |
|
| 46 | 46 | $query->$whereIn($this->getQualifiedLocalKeyName(), $keys); |
| 47 | 47 | }; |
| 48 | 48 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $keys = parent::getKeys($models, $key); |
| 62 | 62 | |
| 63 | - return array_filter($keys, function ($value) { |
|
| 63 | + return array_filter($keys, function($value) { |
|
| 64 | 64 | return !is_null($value); |
| 65 | 65 | }); |
| 66 | 66 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | $key = $this->andSelf ? $this->localKey : $this->getForeignKeyName(); |
| 110 | 110 | |
| 111 | - $constraint = function (Builder $query) use ($key) { |
|
| 111 | + $constraint = function(Builder $query) use ($key) { |
|
| 112 | 112 | $query->whereColumn( |
| 113 | 113 | $query->getQuery()->from.'.'.$this->localKey, |
| 114 | 114 | '=', |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | $key = $this->andSelf ? $this->localKey : $this->getForeignKeyName(); |
| 139 | 139 | |
| 140 | - $constraint = function (Builder $query) use ($table, $key) { |
|
| 140 | + $constraint = function(Builder $query) use ($table, $key) { |
|
| 141 | 141 | $query->whereColumn( |
| 142 | 142 | $table.'.'.$this->localKey, |
| 143 | 143 | '=', |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | public function scopeTree(Builder $query, $maxDepth = null) |
| 18 | 18 | { |
| 19 | - $constraint = function (Builder $query) { |
|
| 19 | + $constraint = function(Builder $query) { |
|
| 20 | 20 | $query->isRoot(); |
| 21 | 21 | }; |
| 22 | 22 | |
@@ -19,13 +19,13 @@ |
||
| 19 | 19 | * @return $this |
| 20 | 20 | */ |
| 21 | 21 | public function withGlobalScopes(array $scopes) |
| 22 | - { |
|
| 23 | - foreach ($scopes as $identifier => $scope) { |
|
| 24 | - $this->withGlobalScope($identifier, $scope); |
|
| 25 | - } |
|
| 22 | + { |
|
| 23 | + foreach ($scopes as $identifier => $scope) { |
|
| 24 | + $this->withGlobalScope($identifier, $scope); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | 27 | return $this; |
| 28 | - } |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * Get the hydrated models without eager loading. |
@@ -4,83 +4,83 @@ |
||
| 4 | 4 | |
| 5 | 5 | trait TracksIntermediateScopes |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * Applied intermediate Scopes. |
|
| 9 | - * |
|
| 10 | - * @var array |
|
| 11 | - */ |
|
| 12 | - protected $intermediateScopes = []; |
|
| 7 | + /** |
|
| 8 | + * Applied intermediate Scopes. |
|
| 9 | + * |
|
| 10 | + * @var array |
|
| 11 | + */ |
|
| 12 | + protected $intermediateScopes = []; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Removed intermediate Scopes. |
|
| 16 | - * |
|
| 17 | - * @var array |
|
| 18 | - */ |
|
| 19 | - protected $removedIntermediateScopes = []; |
|
| 14 | + /** |
|
| 15 | + * Removed intermediate Scopes. |
|
| 16 | + * |
|
| 17 | + * @var array |
|
| 18 | + */ |
|
| 19 | + protected $removedIntermediateScopes = []; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Register a new intermediate scope. |
|
| 23 | - * |
|
| 24 | - * @param string $identifier |
|
| 25 | - * @param \Illuminate\Database\Eloquent\Scope|\Closure $scope |
|
| 26 | - * @return $this |
|
| 27 | - */ |
|
| 28 | - public function withIntermediateScope($identifier, $scope) |
|
| 29 | - { |
|
| 30 | - $this->intermediateScopes[$identifier] = $scope; |
|
| 21 | + /** |
|
| 22 | + * Register a new intermediate scope. |
|
| 23 | + * |
|
| 24 | + * @param string $identifier |
|
| 25 | + * @param \Illuminate\Database\Eloquent\Scope|\Closure $scope |
|
| 26 | + * @return $this |
|
| 27 | + */ |
|
| 28 | + public function withIntermediateScope($identifier, $scope) |
|
| 29 | + { |
|
| 30 | + $this->intermediateScopes[$identifier] = $scope; |
|
| 31 | 31 | |
| 32 | - if (method_exists($scope, 'extend')) { |
|
| 33 | - $scope->extend($this); |
|
| 34 | - } |
|
| 32 | + if (method_exists($scope, 'extend')) { |
|
| 33 | + $scope->extend($this); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - return $this; |
|
| 37 | - } |
|
| 36 | + return $this; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Remove a registered intermediate scope. |
|
| 41 | - * |
|
| 42 | - * @param \Illuminate\Database\Eloquent\Scope|string $scope |
|
| 43 | - * @return $this |
|
| 44 | - */ |
|
| 45 | - public function withoutIntermediateScope($scope) |
|
| 46 | - { |
|
| 47 | - if (!is_string($scope)) { |
|
| 48 | - $scope = get_class($scope); |
|
| 49 | - } |
|
| 39 | + /** |
|
| 40 | + * Remove a registered intermediate scope. |
|
| 41 | + * |
|
| 42 | + * @param \Illuminate\Database\Eloquent\Scope|string $scope |
|
| 43 | + * @return $this |
|
| 44 | + */ |
|
| 45 | + public function withoutIntermediateScope($scope) |
|
| 46 | + { |
|
| 47 | + if (!is_string($scope)) { |
|
| 48 | + $scope = get_class($scope); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - unset($this->intermediateScopes[$scope]); |
|
| 51 | + unset($this->intermediateScopes[$scope]); |
|
| 52 | 52 | |
| 53 | - $this->removedIntermediateScopes[] = $scope; |
|
| 53 | + $this->removedIntermediateScopes[] = $scope; |
|
| 54 | 54 | |
| 55 | - return $this; |
|
| 56 | - } |
|
| 55 | + return $this; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Remove all or passed registered intermediate Scopes. |
|
| 60 | - * |
|
| 61 | - * @param array|null $scopes |
|
| 62 | - * @return $this |
|
| 63 | - */ |
|
| 64 | - public function withoutIntermediateScopes(array $scopes = null) |
|
| 65 | - { |
|
| 66 | - if (!is_array($scopes)) { |
|
| 67 | - $scopes = array_keys($this->intermediateScopes); |
|
| 68 | - } |
|
| 58 | + /** |
|
| 59 | + * Remove all or passed registered intermediate Scopes. |
|
| 60 | + * |
|
| 61 | + * @param array|null $scopes |
|
| 62 | + * @return $this |
|
| 63 | + */ |
|
| 64 | + public function withoutIntermediateScopes(array $scopes = null) |
|
| 65 | + { |
|
| 66 | + if (!is_array($scopes)) { |
|
| 67 | + $scopes = array_keys($this->intermediateScopes); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - foreach ($scopes as $scope) { |
|
| 71 | - $this->withoutIntermediateScope($scope); |
|
| 72 | - } |
|
| 70 | + foreach ($scopes as $scope) { |
|
| 71 | + $this->withoutIntermediateScope($scope); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - return $this; |
|
| 75 | - } |
|
| 74 | + return $this; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Get an array of intermediate Scopes that were removed from the query. |
|
| 79 | - * |
|
| 80 | - * @return array |
|
| 81 | - */ |
|
| 82 | - public function removedIntermediateScopes() |
|
| 83 | - { |
|
| 84 | - return $this->removedIntermediateScopes; |
|
| 85 | - } |
|
| 77 | + /** |
|
| 78 | + * Get an array of intermediate Scopes that were removed from the query. |
|
| 79 | + * |
|
| 80 | + * @return array |
|
| 81 | + */ |
|
| 82 | + public function removedIntermediateScopes() |
|
| 83 | + { |
|
| 84 | + return $this->removedIntermediateScopes; |
|
| 85 | + } |
|
| 86 | 86 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | if (static::$constraints) { |
| 56 | 56 | $column = $this->andSelf ? $this->parent->getLocalKeyName() : $this->parent->getParentKeyName(); |
| 57 | 57 | |
| 58 | - $constraint = function (Builder $query) use ($column) { |
|
| 58 | + $constraint = function(Builder $query) use ($column) { |
|
| 59 | 59 | $query->where( |
| 60 | 60 | $column, |
| 61 | 61 | '=', |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | $keys = $this->getKeys($models, $localKey); |
| 83 | 83 | |
| 84 | - $constraint = function (Builder $query) use ($keys, $localKey, $models, $whereIn) { |
|
| 84 | + $constraint = function(Builder $query) use ($keys, $localKey, $models, $whereIn) { |
|
| 85 | 85 | $query->$whereIn($localKey, $keys); |
| 86 | 86 | }; |
| 87 | 87 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | ? $this->parent->getLocalKeyName() |
| 182 | 182 | : $this->parent->getParentKeyName(); |
| 183 | 183 | |
| 184 | - $constraint = function (Builder $query) use ($first, $table) { |
|
| 184 | + $constraint = function(Builder $query) use ($first, $table) { |
|
| 185 | 185 | $query->whereColumn( |
| 186 | 186 | $table.'.'.$first, |
| 187 | 187 | '=', |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | $query->withRecursiveExpression($name, $expression); |
| 218 | 218 | |
| 219 | - $query->withGlobalScope('HasManyOfDescendants', function (Builder $query) use ($name) { |
|
| 219 | + $query->withGlobalScope('HasManyOfDescendants', function(Builder $query) use ($name) { |
|
| 220 | 220 | $query->whereIn( |
| 221 | 221 | $this->foreignKey, |
| 222 | 222 | (new $this->parent())->setTable($name) |