@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $relationType = $this->getRelationTypeName($relation); |
| 62 | 62 | $method = "fill{$relationType}Relation"; |
| 63 | 63 | |
| 64 | - if (! method_exists($this, $method)) { |
|
| 64 | + if (!method_exists($this, $method)) { |
|
| 65 | 65 | throw new RuntimeException("Unknown or unfillable relation type: {$key} of type ${relationType}"); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $relationType = $this->getRelationTypeName($relation); |
| 83 | 83 | $method = "connect{$relationType}Relation"; |
| 84 | 84 | |
| 85 | - if (! method_exists($this, $method)) { |
|
| 85 | + if (!method_exists($this, $method)) { |
|
| 86 | 86 | throw new RuntimeException("Unknown or unfillable connection type: {$key} of type ${relationType}"); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | protected function connectBelongsToRelation(Relations\BelongsTo $relation, $id) |
| 101 | 101 | { |
| 102 | - if (! $id) { |
|
| 102 | + if (!$id) { |
|
| 103 | 103 | $relation->dissociate(); |
| 104 | 104 | |
| 105 | 105 | return; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | $relation->associate($model); |
| 112 | 112 | |
| 113 | - $this->queue(function () use ($schema) { |
|
| 113 | + $this->queue(function() use ($schema) { |
|
| 114 | 114 | $schema->authorizeToAdd($this->getModel()); |
| 115 | 115 | }); |
| 116 | 116 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | protected function fillBelongsToRelation(Relations\BelongsTo $relation, $attributes = []) |
| 126 | 126 | { |
| 127 | - if (! $attributes) { |
|
| 127 | + if (!$attributes) { |
|
| 128 | 128 | $relation->dissociate(); |
| 129 | 129 | |
| 130 | 130 | return; |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | $relation->associate($model); |
| 138 | 138 | |
| 139 | - $this->queue(function () use ($schema) { |
|
| 139 | + $this->queue(function() use ($schema) { |
|
| 140 | 140 | $schema->authorizeToAdd($this->getModel()); |
| 141 | 141 | }); |
| 142 | 142 | } |
@@ -150,13 +150,13 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | protected function connectHasOneRelation(Relations\HasOne $relation, $id) |
| 152 | 152 | { |
| 153 | - if (! $id) { |
|
| 153 | + if (!$id) { |
|
| 154 | 154 | $relation->delete(); |
| 155 | 155 | |
| 156 | 156 | return; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $this->queue(function () use ($id, $relation) { |
|
| 159 | + $this->queue(function() use ($id, $relation) { |
|
| 160 | 160 | $model = $relation->getRelated()->findOrFail($id); |
| 161 | 161 | $this->authorizeToAdd($model); |
| 162 | 162 | $relation->save($model); |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | protected function fillHasOneRelation(Relations\HasOne $relation, $attributes) |
| 175 | 175 | { |
| 176 | - if (! $attributes) { |
|
| 176 | + if (!$attributes) { |
|
| 177 | 177 | $relation->delete(); |
| 178 | 178 | |
| 179 | 179 | return; |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | $modelSchema->authorizeToCreate(); |
| 185 | 185 | $modelSchema->fill($attributes); |
| 186 | 186 | |
| 187 | - $this->queue(function () use ($modelSchema, $relation) { |
|
| 187 | + $this->queue(function() use ($modelSchema, $relation) { |
|
| 188 | 188 | $this->authorizeToAdd($modelSchema->getModel()); |
| 189 | 189 | $relation->save($modelSchema->getInstance()); |
| 190 | 190 | $modelSchema->save(); |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | protected function connectHasManyRelation(Relations\HasMany $relation, array $ids) |
| 202 | 202 | { |
| 203 | - $this->queue(function () use ($relation, $ids) { |
|
| 203 | + $this->queue(function() use ($relation, $ids) { |
|
| 204 | 204 | $models = $relation->getModel()->findMany($ids); |
| 205 | 205 | |
| 206 | 206 | foreach ($models as $model) { |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | protected function fillHasManyRelation(Relations\HasMany $relation, array $values) |
| 222 | 222 | { |
| 223 | - $this->queue(function () use ($relation, $values) { |
|
| 223 | + $this->queue(function() use ($relation, $values) { |
|
| 224 | 224 | $related = $relation->getRelated(); |
| 225 | 225 | $relation->delete(); |
| 226 | 226 | |
@@ -269,20 +269,20 @@ discard block |
||
| 269 | 269 | ) { |
| 270 | 270 | $values = collect($values); |
| 271 | 271 | |
| 272 | - $this->queue(function () use ($detaching, $relation, $values) { |
|
| 272 | + $this->queue(function() use ($detaching, $relation, $values) { |
|
| 273 | 273 | $current = $relation->newQuery()->pluck($relation->getRelatedPivotKeyName()); |
| 274 | 274 | |
| 275 | 275 | if ($detaching) { |
| 276 | 276 | $detach = $current->diff($values); |
| 277 | 277 | |
| 278 | - $relation->getRelated()->newQuery()->findMany($detach)->each(function (Model $model) { |
|
| 278 | + $relation->getRelated()->newQuery()->findMany($detach)->each(function(Model $model) { |
|
| 279 | 279 | $this->authorizeToDetach($model); |
| 280 | 280 | }); |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | $attach = $values->diff($current); |
| 284 | 284 | |
| 285 | - $relation->getRelated()->newQuery()->findMany($attach)->each(function (Model $model) { |
|
| 285 | + $relation->getRelated()->newQuery()->findMany($attach)->each(function(Model $model) { |
|
| 286 | 286 | $this->authorizeToAttach($model); |
| 287 | 287 | }); |
| 288 | 288 | |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | $pivotClass = $relation->getPivotClass(); |
| 310 | 310 | |
| 311 | 311 | // Returns an associative array of [ id => pivot ] |
| 312 | - $values = collect($values)->mapWithKeys(function ($data) use ($accessor, $relatedKey) { |
|
| 312 | + $values = collect($values)->mapWithKeys(function($data) use ($accessor, $relatedKey) { |
|
| 313 | 313 | return [$data[$relatedKey] => $data[$accessor] ?? []]; |
| 314 | - })->map(function ($attributes) use ($pivotClass) { |
|
| 314 | + })->map(function($attributes) use ($pivotClass) { |
|
| 315 | 315 | $instance = new $pivotClass; |
| 316 | 316 | $pivotSchema = $this->registry->getSchemaForModel($instance); |
| 317 | 317 | $pivotSchema->fill($attributes); |
@@ -319,20 +319,20 @@ discard block |
||
| 319 | 319 | return $pivotSchema->getInstance()->getAttributes(); |
| 320 | 320 | }); |
| 321 | 321 | |
| 322 | - $this->queue(function () use ($values, $detaching, $relation) { |
|
| 322 | + $this->queue(function() use ($values, $detaching, $relation) { |
|
| 323 | 323 | $current = $relation->newQuery()->pluck($relation->getRelatedPivotKeyName()); |
| 324 | 324 | |
| 325 | 325 | if ($detaching) { |
| 326 | 326 | $detach = $current->diff($values->keys()); |
| 327 | 327 | |
| 328 | - $relation->getRelated()->newQuery()->findMany($detach)->each(function (Model $model) { |
|
| 328 | + $relation->getRelated()->newQuery()->findMany($detach)->each(function(Model $model) { |
|
| 329 | 329 | $this->authorizeToDetach($model); |
| 330 | 330 | }); |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | $attach = $values->keys()->diff($current); |
| 334 | 334 | |
| 335 | - $relation->getRelated()->newQuery()->findMany($attach)->each(function (Model $model) use ($values) { |
|
| 335 | + $relation->getRelated()->newQuery()->findMany($attach)->each(function(Model $model) use ($values) { |
|
| 336 | 336 | $this->authorizeToAttach($model, $values->get($model->getKey())); |
| 337 | 337 | }); |
| 338 | 338 | |
@@ -361,8 +361,8 @@ discard block |
||
| 361 | 361 | $pivots[] = $attributes[$accessor] ?? null; |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - $this->queue(function () use ($detaching, $relation, $instances, $pivots) { |
|
| 365 | - $data = $instances->pluck('id')->mapWithKeys(function ($id, $key) use ($pivots) { |
|
| 364 | + $this->queue(function() use ($detaching, $relation, $instances, $pivots) { |
|
| 365 | + $data = $instances->pluck('id')->mapWithKeys(function($id, $key) use ($pivots) { |
|
| 366 | 366 | $pivot = $pivots[$key] ?? null; |
| 367 | 367 | |
| 368 | 368 | return $pivot ? [$id => $pivot] : [$key => $id]; |
@@ -370,11 +370,11 @@ discard block |
||
| 370 | 370 | |
| 371 | 371 | $results = $relation->sync($data, $detaching); |
| 372 | 372 | |
| 373 | - $relation->getRelated()->newQuery()->findMany($results['detached'])->each(function (Model $model) { |
|
| 373 | + $relation->getRelated()->newQuery()->findMany($results['detached'])->each(function(Model $model) { |
|
| 374 | 374 | $this->authorizeToDetach($model); |
| 375 | 375 | }); |
| 376 | 376 | |
| 377 | - $relation->getRelated()->newQuery()->findMany($results['attached'])->each(function (Model $model) { |
|
| 377 | + $relation->getRelated()->newQuery()->findMany($results['attached'])->each(function(Model $model) { |
|
| 378 | 378 | $this->authorizeToAttach($model); |
| 379 | 379 | }); |
| 380 | 380 | }); |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | */ |
| 390 | 390 | protected function connectMorphToRelation(Relations\MorphTo $relation, $data) |
| 391 | 391 | { |
| 392 | - if (! $data) { |
|
| 392 | + if (!$data) { |
|
| 393 | 393 | $relation->dissociate(); |
| 394 | 394 | |
| 395 | 395 | return; |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | |
| 403 | 403 | $data = collect($data); |
| 404 | 404 | |
| 405 | - [$key, $id] = $data->mapWithKeys(function ($item, $key) { |
|
| 405 | + [$key, $id] = $data->mapWithKeys(function($item, $key) { |
|
| 406 | 406 | return [$key, $item]; |
| 407 | 407 | }); |
| 408 | 408 | |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | protected function fillMorphToRelation(Relations\MorphTo $relation, $data) |
| 426 | 426 | { |
| 427 | - if (! $data) { |
|
| 427 | + if (!$data) { |
|
| 428 | 428 | $relation->dissociate(); |
| 429 | 429 | |
| 430 | 430 | return; |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | |
| 438 | 438 | $data = collect($data); |
| 439 | 439 | |
| 440 | - [$key, $attributes] = $data->mapWithKeys(function ($item, $key) { |
|
| 440 | + [$key, $attributes] = $data->mapWithKeys(function($item, $key) { |
|
| 441 | 441 | return [$key, $item]; |
| 442 | 442 | }); |
| 443 | 443 | |
@@ -473,8 +473,8 @@ discard block |
||
| 473 | 473 | */ |
| 474 | 474 | protected function connectMorphManyRelation(Relations\MorphMany $relation, array $ids) |
| 475 | 475 | { |
| 476 | - $this->queue(function () use ($relation, $ids) { |
|
| 477 | - $relation->each(function (Model $model) use ($relation) { |
|
| 476 | + $this->queue(function() use ($relation, $ids) { |
|
| 477 | + $relation->each(function(Model $model) use ($relation) { |
|
| 478 | 478 | $model->setAttribute($relation->getMorphType(), null); |
| 479 | 479 | $model->setAttribute($relation->getForeignKeyName(), null); |
| 480 | 480 | $model->save(); |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | */ |
| 496 | 496 | protected function fillMorphManyRelation(Relations\MorphMany $relation, array $values) |
| 497 | 497 | { |
| 498 | - $this->queue(function () use ($relation, $values) { |
|
| 498 | + $this->queue(function() use ($relation, $values) { |
|
| 499 | 499 | $relation->delete(); |
| 500 | 500 | $related = $relation->getRelated(); |
| 501 | 501 | $relatedSchema = $this->registry->getSchemaForModel($related); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | return array_merge( |
| 34 | 34 | parent::args(), |
| 35 | - $this->modelSchema->getLookupFields()->map(function (Field $field) { |
|
| 35 | + $this->modelSchema->getLookupFields()->map(function(Field $field) { |
|
| 36 | 36 | return $field->getType(); |
| 37 | 37 | })->toArray() |
| 38 | 38 | ); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $input = $args->input->toArray(); |
| 50 | 50 | $model = $this->findOrFail($args); |
| 51 | 51 | |
| 52 | - return DB::transaction(function () use ($input, $model) { |
|
| 52 | + return DB::transaction(function() use ($input, $model) { |
|
| 53 | 53 | $modelSchema = $this->registry->getSchemaForModel($model); |
| 54 | 54 | |
| 55 | 55 | return $modelSchema->updateIfAuthorized($input); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | return $this->modelSchema->getLookupFields() |
| 50 | - ->map(function (Field $field) { |
|
| 50 | + ->map(function(Field $field) { |
|
| 51 | 51 | return $field->getType(); |
| 52 | 52 | }) |
| 53 | 53 | ->merge(['input' => $type]) |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $input = $args->input->toArray(); |
| 77 | 77 | $model = $this->findOrFail($args); |
| 78 | 78 | |
| 79 | - return DB::transaction(function () use ($input, $model) { |
|
| 79 | + return DB::transaction(function() use ($input, $model) { |
|
| 80 | 80 | $modelSchema = $this->registry->getSchemaForModel($model); |
| 81 | 81 | |
| 82 | 82 | $relation = $this->getRelation($model); |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | { |
| 33 | 33 | $input = $args->input->toArray(); |
| 34 | 34 | |
| 35 | - return DB::transaction(function () use ($input) { |
|
| 35 | + return DB::transaction(function() use ($input) { |
|
| 36 | 36 | return $this->getModelSchema()->createIfAuthorized($input); |
| 37 | 37 | }); |
| 38 | 38 | } |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | public function args(): array |
| 43 | 43 | { |
| 44 | - return $this->modelSchema->getLookupFields()->map(function (Field $field) { |
|
| 44 | + return $this->modelSchema->getLookupFields()->map(function(Field $field) { |
|
| 45 | 45 | return $field->getType(); |
| 46 | 46 | })->toArray(); |
| 47 | 47 | } |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | { |
| 64 | 64 | $result = $this->find($args); |
| 65 | 65 | |
| 66 | - if (! $result) { |
|
| 66 | + if (!$result) { |
|
| 67 | 67 | throw (new ModelNotFoundException)->setModel(class_basename($this->model)); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | { |
| 30 | 30 | $fields = collect($this->fields); |
| 31 | 31 | |
| 32 | - return $fields->map(function (RootField $field) { |
|
| 32 | + return $fields->map(function(RootField $field) { |
|
| 33 | 33 | return $field->toArray(); |
| 34 | 34 | }); |
| 35 | 35 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | protected function getModelTypes(): Collection |
| 193 | 193 | { |
| 194 | - return $this->getModels()->reduce(function (Collection $types, string $class) { |
|
| 194 | + return $this->getModels()->reduce(function(Collection $types, string $class) { |
|
| 195 | 195 | $schema = $this->registry->getModelSchema($class); |
| 196 | 196 | |
| 197 | 197 | if ($schema->getModel() instanceof Pivot) { |
@@ -218,26 +218,26 @@ discard block |
||
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | // Filter through the regular fields and get the polymorphic types. |
| 221 | - $schema->getFields()->filter(function ($field) { |
|
| 221 | + $schema->getFields()->filter(function($field) { |
|
| 222 | 222 | return $field instanceof PolymorphicField; |
| 223 | - })->each(function ($field, $key) use ($schema, &$types) { |
|
| 223 | + })->each(function($field, $key) use ($schema, &$types) { |
|
| 224 | 224 | $types = $types->merge($this->getPolymorphicFieldTypes($schema, $key, $field)); |
| 225 | 225 | }); |
| 226 | 226 | |
| 227 | 227 | // Filter through the relations of the model and get the |
| 228 | 228 | // belongsToMany relations and get the pivot input types |
| 229 | 229 | // for that relation. |
| 230 | - $schema->getRelations()->filter(function ($relation) { |
|
| 230 | + $schema->getRelations()->filter(function($relation) { |
|
| 231 | 231 | return $relation instanceof BelongsToMany; |
| 232 | - })->each(function ($relation) use (&$types) { |
|
| 232 | + })->each(function($relation) use (&$types) { |
|
| 233 | 233 | $types = $types->merge($this->getPivotInputTypes($relation)); |
| 234 | 234 | }); |
| 235 | 235 | |
| 236 | 236 | // Filter through the relation fields and get the the |
| 237 | 237 | // polymorphic types for the relations. |
| 238 | - $schema->getRelationFields()->filter(function ($field) { |
|
| 238 | + $schema->getRelationFields()->filter(function($field) { |
|
| 239 | 239 | return $field instanceof PolymorphicField; |
| 240 | - })->each(function ($field, $key) use ($schema, &$types) { |
|
| 240 | + })->each(function($field, $key) use ($schema, &$types) { |
|
| 241 | 241 | $types = $types->merge($this->getPolymorphicRelationshipTypes($schema, $key, $field)); |
| 242 | 242 | }); |
| 243 | 243 | |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | foreach ($this->getModels() as $modelSchema) { |
| 366 | 366 | $modelSchema = $this->registry->getModelSchema($modelSchema); |
| 367 | 367 | |
| 368 | - if (! $modelSchema->getModel() instanceof Pivot) { |
|
| 368 | + if (!$modelSchema->getModel() instanceof Pivot) { |
|
| 369 | 369 | $entityQuery = new SingleEntityQuery($this->registry, $modelSchema); |
| 370 | 370 | $queries->put($entityQuery->getName(), $entityQuery); |
| 371 | 371 | |
@@ -410,11 +410,11 @@ discard block |
||
| 410 | 410 | foreach ($this->getModels() as $class) { |
| 411 | 411 | $modelSchema = $this->registry->getModelSchema($class); |
| 412 | 412 | |
| 413 | - $pivotRelations = $modelSchema->getRelations()->filter(function ($relation) { |
|
| 413 | + $pivotRelations = $modelSchema->getRelations()->filter(function($relation) { |
|
| 414 | 414 | return $relation instanceof BelongsToMany; |
| 415 | 415 | }); |
| 416 | 416 | |
| 417 | - if ($modelSchema->isMutable() && ! $modelSchema->getModel() instanceof Pivot) { |
|
| 417 | + if ($modelSchema->isMutable() && !$modelSchema->getModel() instanceof Pivot) { |
|
| 418 | 418 | $createMutation = new CreateMutation($this->registry, $modelSchema); |
| 419 | 419 | $mutations->put($createMutation->getName(), $createMutation); |
| 420 | 420 | |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | $config->setDirectives(array_merge(Directive::getInternalDirectives(), $this->directives())); |
| 516 | 516 | |
| 517 | 517 | // Set the type loader |
| 518 | - $config->setTypeLoader(function ($name) use ($query, $mutation) { |
|
| 518 | + $config->setTypeLoader(function($name) use ($query, $mutation) { |
|
| 519 | 519 | if ($name === $query->name) { |
| 520 | 520 | return $query; |
| 521 | 521 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | $type = $this->registry->ID()->list(); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - return $this->modelSchema->getLookupFields()->map(function (Field $field) { |
|
| 59 | + return $this->modelSchema->getLookupFields()->map(function(Field $field) { |
|
| 60 | 60 | return $field->getType(); |
| 61 | 61 | })->merge(['input' => $type])->toArray(); |
| 62 | 62 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | $pivotAccessor = $relation->getPivotAccessor(); |
| 78 | 78 | $pivotSchema = $this->getPivotModelSchema(); |
| 79 | 79 | |
| 80 | - $input->map(function ($input) use ($pivotSchema, $relation, $pivotAccessor, $model) { |
|
| 80 | + $input->map(function($input) use ($pivotSchema, $relation, $pivotAccessor, $model) { |
|
| 81 | 81 | $key = $input[$model->getKeyName()] ?? $input; |
| 82 | 82 | $pivotWhere = $input[$pivotAccessor] ?? []; |
| 83 | 83 | |
@@ -95,13 +95,13 @@ discard block |
||
| 95 | 95 | $query->wherePivot($relation->getRelatedPivotKeyName(), $key); |
| 96 | 96 | |
| 97 | 97 | return $query; |
| 98 | - })->map(function (Relations\BelongsToMany $query) use ($modelSchema) { |
|
| 99 | - $query->each(function (Model $related) use ($modelSchema) { |
|
| 98 | + })->map(function(Relations\BelongsToMany $query) use ($modelSchema) { |
|
| 99 | + $query->each(function(Model $related) use ($modelSchema) { |
|
| 100 | 100 | $modelSchema->authorizeToDetach($related); |
| 101 | 101 | }); |
| 102 | 102 | |
| 103 | 103 | return $query; |
| 104 | - })->each(function (Relations\BelongsToMany $query) { |
|
| 104 | + })->each(function(Relations\BelongsToMany $query) { |
|
| 105 | 105 | $query->detach(); |
| 106 | 106 | }); |
| 107 | 107 | |