@@ -176,7 +176,7 @@ |
||
176 | 176 | */ |
177 | 177 | protected function formatIds(array $ids) |
178 | 178 | { |
179 | - return (new BaseCollection($ids))->mapWithKeys(function ($attributes, $id) { |
|
179 | + return (new BaseCollection($ids))->mapWithKeys(function($attributes, $id) { |
|
180 | 180 | if (!is_array($attributes)) { |
181 | 181 | [$id, $attributes] = [$attributes, []]; |
182 | 182 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | if ($position === 0) { |
25 | 25 | $foreignKeys[] = $this->ownerKey; |
26 | 26 | |
27 | - $localKeys[] = function (Builder $query, Builder $parentQuery = null) { |
|
27 | + $localKeys[] = function(Builder $query, Builder $parentQuery = null) { |
|
28 | 28 | if ($parentQuery) { |
29 | 29 | $this->getRelationExistenceQuery($this->query, $parentQuery); |
30 | 30 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $this->mergeWhereConstraints($query, $this->query); |
33 | 33 | }; |
34 | 34 | } else { |
35 | - $foreignKeys[] = function (Builder $query, JoinClause $join) { |
|
35 | + $foreignKeys[] = function(Builder $query, JoinClause $join) { |
|
36 | 36 | $ownerKey = $this->query->qualifyColumn($this->ownerKey); |
37 | 37 | |
38 | 38 | [$sql, $bindings] = $this->relationExistenceQueryOwnerKey($query, $ownerKey); |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | public function appendToDeepRelationship(array $through, array $foreignKeys, array $localKeys, int $position): array |
26 | 26 | { |
27 | 27 | if ($position === 0) { |
28 | - $foreignKeys[] = function (Builder $query, Builder $parentQuery = null) { |
|
28 | + $foreignKeys[] = function(Builder $query, Builder $parentQuery = null) { |
|
29 | 29 | if ($parentQuery) { |
30 | 30 | $this->getRelationExistenceQuery($this->query, $parentQuery); |
31 | 31 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | $localKeys[] = $this->localKey; |
37 | 37 | } else { |
38 | - $foreignKeys[] = function (Builder $query, JoinClause $join) { |
|
38 | + $foreignKeys[] = function(Builder $query, JoinClause $join) { |
|
39 | 39 | [$sql, $bindings] = $this->relationExistenceQueryParentKey($query); |
40 | 40 | |
41 | 41 | $query->addBinding($bindings, 'join'); |
@@ -223,7 +223,7 @@ |
||
223 | 223 | $key = str_replace('->', '.', $this->key); |
224 | 224 | |
225 | 225 | $record = (new BaseCollection($records)) |
226 | - ->filter(function ($value) use ($key, $model) { |
|
226 | + ->filter(function($value) use ($key, $model) { |
|
227 | 227 | return Arr::get($value, $key) == $model->{$this->ownerKey}; |
228 | 228 | })->first(); |
229 | 229 |
@@ -312,10 +312,10 @@ discard block |
||
312 | 312 | public function hasManyThroughJson( |
313 | 313 | string $related, |
314 | 314 | string $through, |
315 | - string|JsonKey $firstKey, |
|
315 | + string | JsonKey $firstKey, |
|
316 | 316 | string $secondKey = null, |
317 | 317 | string $localKey = null, |
318 | - string|JsonKey $secondLocalKey = null |
|
318 | + string | JsonKey $secondLocalKey = null |
|
319 | 319 | ) { |
320 | 320 | $relationships = []; |
321 | 321 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | } else { |
329 | 329 | if (!method_exists($through, 'belongsToJson')) { |
330 | 330 | //@codeCoverageIgnoreStart |
331 | - $message = 'Please add the HasJsonRelationships trait to the ' . $through::class . ' model.'; |
|
331 | + $message = 'Please add the HasJsonRelationships trait to the '.$through::class.' model.'; |
|
332 | 332 | |
333 | 333 | throw new RuntimeException($message); |
334 | 334 | // @codeCoverageIgnoreEnd |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | /** @var \Staudenmeir\EloquentJsonRelations\Relations\HasManyJson $hasManyJson */ |
368 | 368 | $hasManyJson = $relationships[0]; |
369 | 369 | |
370 | - $postGetCallback = function (Collection $models) use ($hasManyJson, $relationships) { |
|
370 | + $postGetCallback = function(Collection $models) use ($hasManyJson, $relationships) { |
|
371 | 371 | if (isset($models[0]->laravel_through_key)) { |
372 | 372 | $hasManyJson->hydratePivotRelation( |
373 | 373 | $models, |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | } |
385 | 385 | |
386 | 386 | $hasManyThroughJson->withCustomEagerMatchingCallback( |
387 | - function (array $models, Collection $results, string $relation) use ($hasManyJson, $hasManyThroughJson) { |
|
387 | + function(array $models, Collection $results, string $relation) use ($hasManyJson, $hasManyThroughJson) { |
|
388 | 388 | foreach ($models as $model) { |
389 | 389 | $hasManyJson->hydratePivotRelation( |
390 | 390 | $model->$relation, |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | |
403 | 403 | $path = $belongsToJson->getForeignKeyPath(); |
404 | 404 | |
405 | - $postProcessor = function (Model $model, array $attributes) use ($belongsToJson, $path) { |
|
405 | + $postProcessor = function(Model $model, array $attributes) use ($belongsToJson, $path) { |
|
406 | 406 | $records = json_decode($attributes[$path], true); |
407 | 407 | |
408 | 408 | return $belongsToJson->pivotAttributes($model, $model, $records); |
@@ -71,18 +71,18 @@ |
||
71 | 71 | */ |
72 | 72 | public function compileMemberOf(string $column, ?string $objectKey, mixed $value): string |
73 | 73 | { |
74 | - $columnWithKey = $objectKey ? $column . (str_contains($column, '->') ? '[*]' : '') . "->$objectKey" : $column; |
|
74 | + $columnWithKey = $objectKey ? $column.(str_contains($column, '->') ? '[*]' : '')."->$objectKey" : $column; |
|
75 | 75 | |
76 | 76 | [$field, $path] = $this->wrapJsonFieldAndPath($columnWithKey); |
77 | 77 | |
78 | 78 | if ($objectKey && !str_contains($column, '->')) { |
79 | - $path = ", '$[*]" . substr($path, 4); |
|
79 | + $path = ", '$[*]".substr($path, 4); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | $sql = $path ? "json_extract($field$path)" : $field; |
83 | 83 | |
84 | 84 | if ($value instanceof Expression) { |
85 | - return $value->getValue($this) . " member of($sql)"; |
|
85 | + return $value->getValue($this)." member of($sql)"; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | return "? member of($sql)"; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | { |
80 | 80 | $parentKeys = $this->getKeys($models, $this->localKey); |
81 | 81 | |
82 | - $this->query->where(function (Builder $query) use ($parentKeys) { |
|
82 | + $this->query->where(function(Builder $query) use ($parentKeys) { |
|
83 | 83 | foreach ($parentKeys as $parentKey) { |
84 | 84 | $this->whereJsonContainsOrMemberOf( |
85 | 85 | $query, |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function getRelationExistenceQueryForSelfRelation(Builder $query, Builder $parentQuery, $columns = ['*']) |
211 | 211 | { |
212 | - $query->from($query->getModel()->getTable() . ' as ' . $hash = $this->getRelationCountHash()); |
|
212 | + $query->from($query->getModel()->getTable().' as '.$hash = $this->getRelationCountHash()); |
|
213 | 213 | |
214 | 214 | $query->getModel()->setTable($hash); |
215 | 215 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | |
220 | 220 | $this->whereJsonContainsOrMemberOf( |
221 | 221 | $query, |
222 | - $hash . '.' . $this->getPathName(), |
|
222 | + $hash.'.'.$this->getPathName(), |
|
223 | 223 | $query->getQuery()->connection->raw($sql) |
224 | 224 | ); |
225 | 225 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | $key = str_replace('->', '.', $this->key); |
274 | 274 | |
275 | 275 | $record = (new BaseCollection($records)) |
276 | - ->filter(function ($value) use ($key, $parent) { |
|
276 | + ->filter(function($value) use ($key, $parent) { |
|
277 | 277 | return Arr::get($value, $key) == $parent->{$this->localKey}; |
278 | 278 | })->first(); |
279 | 279 |