@@ -60,7 +60,7 @@ |
||
60 | 60 | */ |
61 | 61 | public function graphiql(Request $request, Bakery $bakery) |
62 | 62 | { |
63 | - if (! app()->isLocal()) { |
|
63 | + if (!app()->isLocal()) { |
|
64 | 64 | abort(404); |
65 | 65 | } |
66 | 66 |
@@ -7,7 +7,7 @@ |
||
7 | 7 | ->middleware(config('bakery.middleware', [])) |
8 | 8 | ->as('bakery.') |
9 | 9 | ->prefix(config('bakery.path')) |
10 | - ->group(function () { |
|
10 | + ->group(function() { |
|
11 | 11 | $controller = config('bakery.controller', 'BakeryController@graphql'); |
12 | 12 | |
13 | 13 | Route::get('/', $controller)->name('graphql'); |
@@ -92,7 +92,7 @@ |
||
92 | 92 | { |
93 | 93 | foreach ($args as $key => $value) { |
94 | 94 | if ($value instanceof Arguments) { |
95 | - $query->whereHas($key, function (Builder $query) use ($value) { |
|
95 | + $query->whereHas($key, function(Builder $query) use ($value) { |
|
96 | 96 | $this->queryByArgs($query, $value); |
97 | 97 | }); |
98 | 98 | } else { |
@@ -53,7 +53,7 @@ |
||
53 | 53 | */ |
54 | 54 | public function getModelSchemaByKey(string $key) |
55 | 55 | { |
56 | - return collect($this->modelSchemas)->first(function ($definition) use ($key) { |
|
56 | + return collect($this->modelSchemas)->first(function($definition) use ($key) { |
|
57 | 57 | return Utils::single(resolve($definition)->getModel()) === $key; |
58 | 58 | }); |
59 | 59 | } |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | $args = new Arguments($args); |
515 | 515 | |
516 | 516 | if (isset($this->viewPolicy)) { |
517 | - if (! $this->authorizeToRead($root, $info->fieldName)) { |
|
517 | + if (!$this->authorizeToRead($root, $info->fieldName)) { |
|
518 | 518 | return null; |
519 | 519 | } |
520 | 520 | } |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | $policy = $this->viewPolicy; |
556 | 556 | |
557 | 557 | // Check if there is a policy. |
558 | - if (! $policy) { |
|
558 | + if (!$policy) { |
|
559 | 559 | return true; |
560 | 560 | } |
561 | 561 | |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | $policy = $this->storePolicy; |
607 | 607 | |
608 | 608 | // Check if there is a policy. |
609 | - if (! $policy) { |
|
609 | + if (!$policy) { |
|
610 | 610 | return true; |
611 | 611 | } |
612 | 612 | |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | { |
633 | 633 | return [ |
634 | 634 | 'type' => $this->getType()->toType(), |
635 | - 'args' => collect($this->getArgs())->map(function (RootType $type) { |
|
635 | + 'args' => collect($this->getArgs())->map(function(RootType $type) { |
|
636 | 636 | return $type->toType(); |
637 | 637 | })->toArray(), |
638 | 638 | 'resolve' => [$this, 'resolveField'], |
@@ -25,7 +25,7 @@ |
||
25 | 25 | */ |
26 | 26 | public static function bootBakeryTransactionalAware() |
27 | 27 | { |
28 | - Event::listen('eloquent.booted: '.static::class, function (Model $model) { |
|
28 | + Event::listen('eloquent.booted: '.static::class, function(Model $model) { |
|
29 | 29 | $model->addObservableEvents(['persisting', 'persisted']); |
30 | 30 | }); |
31 | 31 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function create(array $input = []): Model |
62 | 62 | { |
63 | - return $this->transaction(function () use ($input) { |
|
63 | + return $this->transaction(function() use ($input) { |
|
64 | 64 | $this->make($input); |
65 | 65 | $this->save(); |
66 | 66 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function createIfAuthorized(array $input = []): Model |
78 | 78 | { |
79 | - return $this->transaction(function () use ($input) { |
|
79 | + return $this->transaction(function() use ($input) { |
|
80 | 80 | $this->create($input); |
81 | 81 | $this->authorizeToCreate(); |
82 | 82 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function update(array $input = []): Model |
107 | 107 | { |
108 | - return $this->transaction(function () use ($input) { |
|
108 | + return $this->transaction(function() use ($input) { |
|
109 | 109 | $this->fill($input); |
110 | 110 | $this->save(); |
111 | 111 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function authorizeToCreate(): void |
19 | 19 | { |
20 | - if (! static::authorizedToCreate()) { |
|
20 | + if (!static::authorizedToCreate()) { |
|
21 | 21 | throw new AuthorizationException("Not allowed to perform create on {$this->getModelClass()}"); |
22 | 22 | } |
23 | 23 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function authorize(string $ability, $arguments = []): void |
167 | 167 | { |
168 | - if (! $this->authorized($ability, $arguments)) { |
|
168 | + if (!$this->authorized($ability, $arguments)) { |
|
169 | 169 | throw new AuthorizationException("Not allowed to perform {$ability} on {$this->getModelClass()}"); |
170 | 170 | } |
171 | 171 | } |
@@ -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); |