@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $fields = collect(); |
| 54 | 54 | |
| 55 | - $this->modelSchema->getFields()->each(function (Field $field, string $key) use ($fields) { |
|
| 55 | + $this->modelSchema->getFields()->each(function(Field $field, string $key) use ($fields) { |
|
| 56 | 56 | if ($field instanceof PolymorphicField) { |
| 57 | 57 | $fields = $fields->merge($this->getFieldsForPolymorphicField($key, $field)); |
| 58 | 58 | } else { |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $field = $field->args([ |
| 128 | 128 | 'filter' => $this->registry->type($field->getName().'Filter')->nullable(), |
| 129 | - ])->resolve(function (Model $model, string $accessor, Arguments $args) use ($field) { |
|
| 129 | + ])->resolve(function(Model $model, string $accessor, Arguments $args) use ($field) { |
|
| 130 | 130 | $relation = $field->getRelation($model); |
| 131 | 131 | |
| 132 | 132 | return $args->isEmpty() ? $field->getResult($model) : $this->getRelationQuery($relation, $args)->get(); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | ->args($field->getArgs()) |
| 141 | 141 | ->nullable($field->isNullable()) |
| 142 | 142 | ->viewPolicy($field->getViewPolicy()) |
| 143 | - ->resolve(function (Model $model, string $accessor, Arguments $args) use ($field) { |
|
| 143 | + ->resolve(function(Model $model, string $accessor, Arguments $args) use ($field) { |
|
| 144 | 144 | $relation = $field->getRelation($model); |
| 145 | 145 | |
| 146 | 146 | $result = $args->isEmpty() ? $field->getResult($model) : $this->getRelationQuery($relation, $args)->get(); |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | ->accessor($field->getAccessor()) |
| 154 | 154 | ->nullable($field->isNullable()) |
| 155 | 155 | ->viewPolicy($field->getViewPolicy()) |
| 156 | - ->resolve(function (Model $model, string $accessor, Arguments $args) use ($field) { |
|
| 156 | + ->resolve(function(Model $model, string $accessor, Arguments $args) use ($field) { |
|
| 157 | 157 | $relation = $field->getRelation($model); |
| 158 | 158 | |
| 159 | 159 | $result = $args->isEmpty() ? $field->getResult($model) : $this->getRelationQuery($relation, $args)->get(); |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | ->accessor($field->getAccessor()) |
| 183 | 183 | ->nullable($field->isNullable()) |
| 184 | 184 | ->viewPolicy($field->getViewPolicy()) |
| 185 | - ->resolve(function (Model $model, string $accessor) { |
|
| 185 | + ->resolve(function(Model $model, string $accessor) { |
|
| 186 | 186 | $relation = $model->{$accessor}; |
| 187 | 187 | |
| 188 | 188 | return $relation ? $relation->getKey() : null; |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | $fields = collect(); |
| 204 | 204 | $pivot = $relation->getPivotClass(); |
| 205 | 205 | |
| 206 | - if (! $this->registry->hasSchemaForModel($pivot)) { |
|
| 206 | + if (!$this->registry->hasSchemaForModel($pivot)) { |
|
| 207 | 207 | return $fields; |
| 208 | 208 | } |
| 209 | 209 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | $related = $relation->getRelated(); |
| 214 | 214 | |
| 215 | - if (! $field->getInverse()) { |
|
| 215 | + if (!$field->getInverse()) { |
|
| 216 | 216 | $modelClassName = class_basename($this->model); |
| 217 | 217 | $relatedClassName = class_basename($related); |
| 218 | 218 | $guess = Utils::plural($modelClassName); |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | $accessor = $inverseRelation->getPivotAccessor(); |
| 234 | 234 | |
| 235 | 235 | $fields->put($pivotKey, $this->registry->field($modelSchema->typename()) |
| 236 | - ->resolve(function ($model) use ($accessor) { |
|
| 236 | + ->resolve(function($model) use ($accessor) { |
|
| 237 | 237 | return $model->{$accessor}; |
| 238 | 238 | }) |
| 239 | 239 | ); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | $field = $schema->getFieldByKey($key); |
| 29 | 29 | |
| 30 | 30 | // Skip if this is not a defined field. |
| 31 | - if (! $field) { |
|
| 31 | + if (!$field) { |
|
| 32 | 32 | continue; |
| 33 | 33 | } |
| 34 | 34 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | continue; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - $with = array_map(function ($with) use ($path) { |
|
| 40 | + $with = array_map(function($with) use ($path) { |
|
| 41 | 41 | return $path ? "{$path}.{$with}" : $with; |
| 42 | 42 | }, $field->getWith() ?? []); |
| 43 | 43 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | { |
| 195 | 195 | $key = $this->instance->getKeyName(); |
| 196 | 196 | |
| 197 | - if (! $key) { |
|
| 197 | + if (!$key) { |
|
| 198 | 198 | return []; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | public function getFields(): Collection |
| 215 | 215 | { |
| 216 | - return collect($this->getKeyField())->merge($this->fields())->map(function (Field $field, string $key) { |
|
| 217 | - if (! $field->getAccessor()) { |
|
| 216 | + return collect($this->getKeyField())->merge($this->fields())->map(function(Field $field, string $key) { |
|
| 217 | + if (!$field->getAccessor()) { |
|
| 218 | 218 | $field->accessor($key); |
| 219 | 219 | } |
| 220 | 220 | |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public function getFillableFields(): Collection |
| 234 | 234 | { |
| 235 | - return $this->getFields()->filter(function (Field $field) { |
|
| 235 | + return $this->getFields()->filter(function(Field $field) { |
|
| 236 | 236 | return $field->isFillable(); |
| 237 | 237 | }); |
| 238 | 238 | } |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | public function getSearchableFields(): Collection |
| 246 | 246 | { |
| 247 | - return $this->getFields()->filter(function (Field $field) { |
|
| 247 | + return $this->getFields()->filter(function(Field $field) { |
|
| 248 | 248 | return $field->isSearchable(); |
| 249 | 249 | }); |
| 250 | 250 | } |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | public function getSearchableRelationFields(): Collection |
| 258 | 258 | { |
| 259 | - return $this->getRelationFields()->filter(function (Field $field) { |
|
| 259 | + return $this->getRelationFields()->filter(function(Field $field) { |
|
| 260 | 260 | return $field->isSearchable(); |
| 261 | 261 | }); |
| 262 | 262 | } |
@@ -269,15 +269,15 @@ discard block |
||
| 269 | 269 | public function getLookupFields(): Collection |
| 270 | 270 | { |
| 271 | 271 | $fields = collect($this->getFields()) |
| 272 | - ->filter(function (Field $field) { |
|
| 272 | + ->filter(function(Field $field) { |
|
| 273 | 273 | return $field->isUnique(); |
| 274 | 274 | }); |
| 275 | 275 | |
| 276 | 276 | $relations = collect($this->getRelationFields()) |
| 277 | - ->filter(function ($field) { |
|
| 277 | + ->filter(function($field) { |
|
| 278 | 278 | return $field instanceof EloquentField; |
| 279 | 279 | }) |
| 280 | - ->map(function (EloquentField $field) { |
|
| 280 | + ->map(function(EloquentField $field) { |
|
| 281 | 281 | $lookupTypeName = $field->getName().'LookupType'; |
| 282 | 282 | |
| 283 | 283 | return $this->registry->field($lookupTypeName); |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | return collect() |
| 287 | 287 | ->merge($fields) |
| 288 | 288 | ->merge($relations) |
| 289 | - ->map(function (Field $field) { |
|
| 289 | + ->map(function(Field $field) { |
|
| 290 | 290 | return $field->nullable(); |
| 291 | 291 | }); |
| 292 | 292 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | */ |
| 299 | 299 | public function getLookupTypes(): Collection |
| 300 | 300 | { |
| 301 | - return $this->getLookupFields()->map(function (Field $field) { |
|
| 301 | + return $this->getLookupFields()->map(function(Field $field) { |
|
| 302 | 302 | return $field->getType(); |
| 303 | 303 | }); |
| 304 | 304 | } |
@@ -310,12 +310,12 @@ discard block |
||
| 310 | 310 | */ |
| 311 | 311 | public function getRelationFields(): Collection |
| 312 | 312 | { |
| 313 | - return collect($this->relations())->map(function (Field $field, string $key) { |
|
| 314 | - if (! $field->getAccessor()) { |
|
| 313 | + return collect($this->relations())->map(function(Field $field, string $key) { |
|
| 314 | + if (!$field->getAccessor()) { |
|
| 315 | 315 | $field->accessor($key); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - if (! $field->getWith()) { |
|
| 318 | + if (!$field->getWith()) { |
|
| 319 | 319 | $field->with($field->getAccessor()); |
| 320 | 320 | } |
| 321 | 321 | |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | */ |
| 331 | 331 | public function getFillableRelationFields(): Collection |
| 332 | 332 | { |
| 333 | - return $this->getRelationFields()->filter(function (Field $field) { |
|
| 333 | + return $this->getRelationFields()->filter(function(Field $field) { |
|
| 334 | 334 | return $field->isFillable(); |
| 335 | 335 | }); |
| 336 | 336 | } |
@@ -343,13 +343,13 @@ discard block |
||
| 343 | 343 | */ |
| 344 | 344 | public function getRelations(): Collection |
| 345 | 345 | { |
| 346 | - return collect($this->relations())->map(function (Field $field, string $key) { |
|
| 347 | - if (! $field->getAccessor()) { |
|
| 346 | + return collect($this->relations())->map(function(Field $field, string $key) { |
|
| 347 | + if (!$field->getAccessor()) { |
|
| 348 | 348 | $field->accessor($key); |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | return $field; |
| 352 | - })->map(function (Field $field) { |
|
| 352 | + })->map(function(Field $field) { |
|
| 353 | 353 | if ($field instanceof EloquentField) { |
| 354 | 354 | return $field->getRelation($this->getModel()); |
| 355 | 355 | } |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | public function getFieldByKey(string $key): ?Field |
| 375 | 375 | { |
| 376 | 376 | return $this->getFields()->merge($this->getRelationFields()) |
| 377 | - ->first(function (Field $field, $fieldKey) use ($key) { |
|
| 377 | + ->first(function(Field $field, $fieldKey) use ($key) { |
|
| 378 | 378 | return $fieldKey === $key; |
| 379 | 379 | }); |
| 380 | 380 | } |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | */ |
| 387 | 387 | public function getConnections(): Collection |
| 388 | 388 | { |
| 389 | - return collect($this->getRelationFields())->map(function (Field $field, $key) { |
|
| 389 | + return collect($this->getRelationFields())->map(function(Field $field, $key) { |
|
| 390 | 390 | return $field->isList() ? Str::singular($key).'Ids' : $key.'Id'; |
| 391 | 391 | }); |
| 392 | 392 | } |