@@ -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); |
@@ -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 |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * @param string|array|null $localKey |
317 | 317 | * @return \Staudenmeir\EloquentJsonRelations\Relations\HasOneJson |
318 | 318 | */ |
319 | - public function hasOneJson(string $related, string|array $foreignKey, string|array|null $localKey = null): HasOneJson |
|
319 | + public function hasOneJson(string $related, string | array $foreignKey, string | array | null $localKey = null): HasOneJson |
|
320 | 320 | { |
321 | 321 | /** @var \Illuminate\Database\Eloquent\Model $instance */ |
322 | 322 | $instance = $this->newRelatedInstance($related); |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | * @param string|array $localKey |
350 | 350 | * @return \Staudenmeir\EloquentJsonRelations\Relations\HasOneJson |
351 | 351 | */ |
352 | - protected function newHasOneJson(Builder $query, Model $parent, string|array $foreignKey, string|array $localKey): HasOneJson |
|
352 | + protected function newHasOneJson(Builder $query, Model $parent, string | array $foreignKey, string | array $localKey): HasOneJson |
|
353 | 353 | { |
354 | 354 | return new HasOneJson($query, $parent, $foreignKey, $localKey); |
355 | 355 | } |
@@ -368,10 +368,10 @@ discard block |
||
368 | 368 | public function hasManyThroughJson( |
369 | 369 | string $related, |
370 | 370 | string $through, |
371 | - string|JsonKey $firstKey, |
|
371 | + string | JsonKey $firstKey, |
|
372 | 372 | string $secondKey = null, |
373 | 373 | string $localKey = null, |
374 | - string|JsonKey $secondLocalKey = null |
|
374 | + string | JsonKey $secondLocalKey = null |
|
375 | 375 | ) { |
376 | 376 | $relationships = []; |
377 | 377 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | } else { |
385 | 385 | if (!method_exists($through, 'belongsToJson')) { |
386 | 386 | //@codeCoverageIgnoreStart |
387 | - $message = 'Please add the HasJsonRelationships trait to the ' . $through::class . ' model.'; |
|
387 | + $message = 'Please add the HasJsonRelationships trait to the '.$through::class.' model.'; |
|
388 | 388 | |
389 | 389 | throw new RuntimeException($message); |
390 | 390 | // @codeCoverageIgnoreEnd |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | /** @var \Staudenmeir\EloquentJsonRelations\Relations\HasManyJson $hasManyJson */ |
424 | 424 | $hasManyJson = $relationships[0]; |
425 | 425 | |
426 | - $postGetCallback = function (Collection $models) use ($hasManyJson, $relationships) { |
|
426 | + $postGetCallback = function(Collection $models) use ($hasManyJson, $relationships) { |
|
427 | 427 | if (isset($models[0]->laravel_through_key)) { |
428 | 428 | $hasManyJson->hydratePivotRelation( |
429 | 429 | $models, |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | } |
441 | 441 | |
442 | 442 | $hasManyThroughJson->withCustomEagerMatchingCallback( |
443 | - function (array $models, Collection $results, string $relation) use ($hasManyJson, $hasManyThroughJson) { |
|
443 | + function(array $models, Collection $results, string $relation) use ($hasManyJson, $hasManyThroughJson) { |
|
444 | 444 | foreach ($models as $model) { |
445 | 445 | $hasManyJson->hydratePivotRelation( |
446 | 446 | $model->$relation, |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | |
459 | 459 | $path = $belongsToJson->getForeignKeyPath(); |
460 | 460 | |
461 | - $postProcessor = function (Model $model, array $attributes) use ($belongsToJson, $path) { |
|
461 | + $postProcessor = function(Model $model, array $attributes) use ($belongsToJson, $path) { |
|
462 | 462 | $records = json_decode($attributes[$path], true); |
463 | 463 | |
464 | 464 | return $belongsToJson->pivotAttributes($model, $model, $records); |