@@ -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 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | protected function addRelationship(ModelsCommand $command, ReflectionMethod $method, Relation $relationship): void |
48 | 48 | { |
49 | - $type = '\\' . Collection::class . '|\\' . $relationship->getRelated()::class . '[]'; |
|
49 | + $type = '\\'.Collection::class.'|\\'.$relationship->getRelated()::class.'[]'; |
|
50 | 50 | |
51 | 51 | $command->setProperty( |
52 | 52 | $method->getName(), |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | ); |
57 | 57 | |
58 | 58 | $command->setProperty( |
59 | - Str::snake($method->getName()) . '_count', |
|
59 | + Str::snake($method->getName()).'_count', |
|
60 | 60 | 'int', |
61 | 61 | true, |
62 | 62 | false, |
@@ -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)"; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | protected function addEagerConstraintsWithCompositeKey(array $models): void |
47 | 47 | { |
48 | 48 | $keys = (new BaseCollection($models))->map( |
49 | - function (Model $model) { |
|
49 | + function(Model $model) { |
|
50 | 50 | return array_map( |
51 | 51 | fn (string $column) => $model[$column], |
52 | 52 | $this->localKey |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | )->values()->unique(null, true)->all(); |
56 | 56 | |
57 | 57 | $this->query->where( |
58 | - function (Builder $query) use ($keys) { |
|
58 | + function(Builder $query) use ($keys) { |
|
59 | 59 | foreach ($keys as $key) { |
60 | 60 | $query->orWhere( |
61 | - function (Builder $query) use ($key) { |
|
61 | + function(Builder $query) use ($key) { |
|
62 | 62 | foreach ($this->foreignKey as $i => $column) { |
63 | 63 | if ($i === 0) { |
64 | 64 | $this->whereJsonContainsOrMemberOf( |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $additionalColumns |
134 | 134 | ); |
135 | 135 | |
136 | - foreach($result->$foreignKey as $value) { |
|
136 | + foreach ($result->$foreignKey as $value) { |
|
137 | 137 | $values = [$value, ...$additionalValues]; |
138 | 138 | |
139 | 139 | $key = implode("\0", $values); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | protected function addEagerConstraintsWithCompositeKey(array $models): void |
47 | 47 | { |
48 | 48 | $keys = (new BaseCollection($models))->map( |
49 | - function (Model $model) { |
|
49 | + function(Model $model) { |
|
50 | 50 | return array_map( |
51 | 51 | fn (string $column) => $model[$column], |
52 | 52 | $this->foreignKey |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | )->values()->unique(null, true)->all(); |
56 | 56 | |
57 | 57 | $this->query->where( |
58 | - function (Builder $query) use ($keys) { |
|
58 | + function(Builder $query) use ($keys) { |
|
59 | 59 | foreach ($keys as $key) { |
60 | 60 | $query->orWhere( |
61 | - function (Builder $query) use ($key) { |
|
61 | + function(Builder $query) use ($key) { |
|
62 | 62 | foreach ($this->ownerKey as $i => $column) { |
63 | 63 | if ($i === 0) { |
64 | 64 | $query->whereIn( |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | |
129 | 129 | $parentKeys = $this->getKeys($models, $this->localKey); |
130 | 130 | |
131 | - $this->query->where(function (Builder $query) use ($parentKeys) { |
|
131 | + $this->query->where(function(Builder $query) use ($parentKeys) { |
|
132 | 132 | foreach ($parentKeys as $parentKey) { |
133 | 133 | $this->whereJsonContainsOrMemberOf( |
134 | 134 | $query, |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public function getRelationExistenceQueryForSelfRelation(Builder $query, Builder $parentQuery, $columns = ['*']) |
268 | 268 | { |
269 | - $query->from($query->getModel()->getTable() . ' as ' . $hash = $this->getRelationCountHash()); |
|
269 | + $query->from($query->getModel()->getTable().' as '.$hash = $this->getRelationCountHash()); |
|
270 | 270 | |
271 | 271 | $query->getModel()->setTable($hash); |
272 | 272 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | $this->whereJsonContainsOrMemberOf( |
278 | 278 | $query, |
279 | - $hash . '.' . $this->getPathName(), |
|
279 | + $hash.'.'.$this->getPathName(), |
|
280 | 280 | $query->getQuery()->connection->raw($sql) |
281 | 281 | ); |
282 | 282 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $localKey = $this->hasCompositeKey() ? $this->localKey[0] : $this->localKey; |
333 | 333 | |
334 | 334 | $record = (new BaseCollection($records)) |
335 | - ->filter(function ($value) use ($key, $localKey, $parent) { |
|
335 | + ->filter(function($value) use ($key, $localKey, $parent) { |
|
336 | 336 | return Arr::get($value, $key) == $parent->$localKey; |
337 | 337 | })->first(); |
338 | 338 |
@@ -315,7 +315,7 @@ |
||
315 | 315 | $ownerKey = $this->hasCompositeKey() ? $this->ownerKey[0] : $this->ownerKey; |
316 | 316 | |
317 | 317 | $record = (new BaseCollection($records)) |
318 | - ->filter(function ($value) use ($key, $model, $ownerKey) { |
|
318 | + ->filter(function($value) use ($key, $model, $ownerKey) { |
|
319 | 319 | return Arr::get($value, $key) == $model->$ownerKey; |
320 | 320 | })->first(); |
321 | 321 |
@@ -321,10 +321,10 @@ discard block |
||
321 | 321 | public function hasManyThroughJson( |
322 | 322 | string $related, |
323 | 323 | string $through, |
324 | - string|JsonKey $firstKey, |
|
324 | + string | JsonKey $firstKey, |
|
325 | 325 | ?string $secondKey = null, |
326 | 326 | ?string $localKey = null, |
327 | - string|JsonKey|null $secondLocalKey = null |
|
327 | + string | JsonKey | null $secondLocalKey = null |
|
328 | 328 | ) { |
329 | 329 | $relationships = []; |
330 | 330 | |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | } else { |
338 | 338 | if (!method_exists($through, 'belongsToJson')) { |
339 | 339 | //@codeCoverageIgnoreStart |
340 | - $message = 'Please add the HasJsonRelationships trait to the ' . $through::class . ' model.'; |
|
340 | + $message = 'Please add the HasJsonRelationships trait to the '.$through::class.' model.'; |
|
341 | 341 | |
342 | 342 | throw new RuntimeException($message); |
343 | 343 | // @codeCoverageIgnoreEnd |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | /** @var \Staudenmeir\EloquentJsonRelations\Relations\HasManyJson $hasManyJson */ |
377 | 377 | $hasManyJson = $relationships[0]; |
378 | 378 | |
379 | - $postGetCallback = function (Collection $models) use ($hasManyJson, $relationships) { |
|
379 | + $postGetCallback = function(Collection $models) use ($hasManyJson, $relationships) { |
|
380 | 380 | if (isset($models[0]->laravel_through_key)) { |
381 | 381 | $hasManyJson->hydratePivotRelation( |
382 | 382 | $models, |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | } |
394 | 394 | |
395 | 395 | $hasManyThroughJson->withCustomEagerMatchingCallback( |
396 | - function (array $models, Collection $results, string $relation) use ($hasManyJson, $hasManyThroughJson) { |
|
396 | + function(array $models, Collection $results, string $relation) use ($hasManyJson, $hasManyThroughJson) { |
|
397 | 397 | foreach ($models as $model) { |
398 | 398 | $hasManyJson->hydratePivotRelation( |
399 | 399 | $model->$relation, |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | |
412 | 412 | $path = $belongsToJson->getForeignKeyPath(); |
413 | 413 | |
414 | - $postProcessor = function (Model $model, array $attributes) use ($belongsToJson, $path) { |
|
414 | + $postProcessor = function(Model $model, array $attributes) use ($belongsToJson, $path) { |
|
415 | 415 | $records = json_decode($attributes[$path], true); |
416 | 416 | |
417 | 417 | return $belongsToJson->pivotAttributes($model, $model, $records); |
@@ -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); |