@@ -214,7 +214,7 @@ public static function newModel(): Model
214214
215215 public static function query (RestifyRequest $ request )
216216 {
217- if (!$ request ->isViaRepository ()) {
217+ if (! $ request ->isViaRepository ()) {
218218 return static ::newModel ()->query ();
219219 }
220220
@@ -279,8 +279,8 @@ public function collectFields(RestifyRequest $request)
279279
280280 if ($ this instanceof Mergeable) {
281281 $ fillable = collect ($ this ->resource ->getFillable ())
282- ->filter (fn ($ attribute ) => $ fields ->contains ('attribute ' , $ attribute ) === false )
283- ->map (fn ($ attribute ) => Field::new ($ attribute ));
282+ ->filter (fn ($ attribute ) => $ fields ->contains ('attribute ' , $ attribute ) === false )
283+ ->map (fn ($ attribute ) => Field::new ($ attribute ));
284284
285285 $ fields = $ fields ->merge ($ fillable );
286286 }
@@ -291,14 +291,14 @@ public function collectFields(RestifyRequest $request)
291291 private function indexFields (RestifyRequest $ request ): Collection
292292 {
293293 return $ this ->collectFields ($ request )
294- ->filter (fn (Field $ field ) => !$ field ->isHiddenOnIndex ($ request , $ this ))
294+ ->filter (fn (Field $ field ) => ! $ field ->isHiddenOnIndex ($ request , $ this ))
295295 ->values ();
296296 }
297297
298298 private function showFields (RestifyRequest $ request ): Collection
299299 {
300300 return $ this ->collectFields ($ request )
301- ->filter (fn (Field $ field ) => !$ field ->isHiddenOnShow ($ request , $ this ))
301+ ->filter (fn (Field $ field ) => ! $ field ->isHiddenOnShow ($ request , $ this ))
302302 ->values ();
303303 }
304304
@@ -412,10 +412,10 @@ public static function routes(Router $router, $attributes, $wrap = false)
412412 public function resolveShowAttributes (RestifyRequest $ request )
413413 {
414414 $ fields = $ this ->showFields ($ request )
415- ->filter (fn (Field $ field ) => $ field ->authorize ($ request ))
416- ->each (fn (Field $ field ) => $ field ->resolveForShow ($ this ))
417- ->map (fn (Field $ field ) => $ field ->serializeToValue ($ request ))
418- ->mapWithKeys (fn ($ value ) => $ value )
415+ ->filter (fn (Field $ field ) => $ field ->authorize ($ request ))
416+ ->each (fn (Field $ field ) => $ field ->resolveForShow ($ this ))
417+ ->map (fn (Field $ field ) => $ field ->serializeToValue ($ request ))
418+ ->mapWithKeys (fn ($ value ) => $ value )
419419 ->all ();
420420
421421 if ($ this instanceof Mergeable) {
@@ -433,7 +433,7 @@ public function resolveShowAttributes(RestifyRequest $request)
433433 return false ;
434434 }
435435
436- if (!$ field ->authorize ($ request )) {
436+ if (! $ field ->authorize ($ request )) {
437437 return false ;
438438 }
439439
@@ -454,10 +454,10 @@ public function resolveIndexAttributes($request)
454454 {
455455 // Resolve the show method, and attach the value to the array
456456 $ fields = $ this ->indexFields ($ request )
457- ->filter (fn (Field $ field ) => $ field ->authorize ($ request ))
458- ->each (fn (Field $ field ) => $ field ->resolveForIndex ($ this ))
459- ->map (fn (Field $ field ) => $ field ->serializeToValue ($ request ))
460- ->mapWithKeys (fn ($ value ) => $ value )
457+ ->filter (fn (Field $ field ) => $ field ->authorize ($ request ))
458+ ->each (fn (Field $ field ) => $ field ->resolveForIndex ($ this ))
459+ ->map (fn (Field $ field ) => $ field ->serializeToValue ($ request ))
460+ ->mapWithKeys (fn ($ value ) => $ value )
461461 ->all ();
462462
463463 if ($ this instanceof Mergeable) {
@@ -475,7 +475,7 @@ public function resolveIndexAttributes($request)
475475 return false ;
476476 }
477477
478- if (!$ field ->authorize ($ request )) {
478+ if (! $ field ->authorize ($ request )) {
479479 return false ;
480480 }
481481
@@ -542,7 +542,7 @@ public function resolveRelationships($request): array
542542 }
543543
544544 $ withs [$ relation ] = $ paginator instanceof Collection
545- ? $ paginator ->map (fn (Model $ item ) => [
545+ ? $ paginator ->map (fn (Model $ item ) => [
546546 'attributes ' => $ item ->toArray (),
547547 ])
548548 : $ paginator ;
@@ -599,10 +599,10 @@ public function index(RestifyRequest $request)
599599
600600 return $ this ->response ([
601601 'meta ' => $ this ->resolveIndexMainMeta (
602- $ request , $ items ->map (fn (self $ repository ) => $ repository ->resource ), RepositoryCollection::meta ($ paginator ->toArray ())
602+ $ request , $ items ->map (fn (self $ repository ) => $ repository ->resource ), RepositoryCollection::meta ($ paginator ->toArray ())
603603 ) ?? RepositoryCollection::meta ($ paginator ->toArray ()),
604604 'links ' => RepositoryCollection::paginationLinks ($ paginator ->toArray ()),
605- 'data ' => $ items ->map (fn (self $ repository ) => $ repository ->serializeForIndex ($ request )),
605+ 'data ' => $ items ->map (fn (self $ repository ) => $ repository ->serializeForIndex ($ request )),
606606 ]);
607607 }
608608
@@ -640,7 +640,7 @@ public function store(RestifyRequest $request)
640640 }
641641 }
642642
643- $ this ->storeFields ($ request )->each (fn (Field $ field ) => $ field ->invokeAfter ($ request , $ this ->resource ));
643+ $ this ->storeFields ($ request )->each (fn (Field $ field ) => $ field ->invokeAfter ($ request , $ this ->resource ));
644644 });
645645
646646 static ::stored ($ this ->resource , $ request );
@@ -664,7 +664,7 @@ public function storeBulk(RepositoryStoreBulkRequest $request)
664664
665665 $ this ->resource ->save ();
666666
667- $ this ->storeBulkFields ($ request )->each (fn (Field $ field ) => $ field ->invokeAfter ($ request , $ this ->resource ));
667+ $ this ->storeBulkFields ($ request )->each (fn (Field $ field ) => $ field ->invokeAfter ($ request , $ this ->resource ));
668668
669669 return $ this ->resource ;
670670 });
@@ -711,8 +711,8 @@ public function updateBulk(RestifyRequest $request, $repositoryId, int $row)
711711 public function attach (RestifyRequest $ request , $ repositoryId , Collection $ pivots )
712712 {
713713 DB ::transaction (function () use ($ request , $ pivots ) {
714- return $ pivots ->map (fn ($ pivot ) => $ pivot ->forceFill ($ request ->except ($ request ->relatedRepository )))
715- ->map (fn ($ pivot ) => $ pivot ->save ());
714+ return $ pivots ->map (fn ($ pivot ) => $ pivot ->forceFill ($ request ->except ($ request ->relatedRepository )))
715+ ->map (fn ($ pivot ) => $ pivot ->save ());
716716 });
717717
718718 return $ this ->response ()
@@ -723,7 +723,7 @@ public function attach(RestifyRequest $request, $repositoryId, Collection $pivot
723723 public function detach (RestifyRequest $ request , $ repositoryId , Collection $ pivots )
724724 {
725725 $ deleted = DB ::transaction (function () use ($ pivots ) {
726- return $ pivots ->map (fn ($ pivot ) => $ pivot ->delete ());
726+ return $ pivots ->map (fn ($ pivot ) => $ pivot ->delete ());
727727 });
728728
729729 return $ this ->response ()
@@ -833,7 +833,7 @@ public function response($content = '', $status = 200, array $headers = []): Res
833833 public function serializeForShow (RestifyRequest $ request ): array
834834 {
835835 return $ this ->filter ([
836- 'id ' => $ this ->when ($ this ->resource ->id , fn () => $ this ->getShowId ($ request )),
836+ 'id ' => $ this ->when ($ this ->resource ->id , fn () => $ this ->getShowId ($ request )),
837837 'type ' => $ this ->when ($ type = $ this ->getType ($ request ), $ type ),
838838 'attributes ' => $ request ->isShowRequest () ? $ this ->resolveShowAttributes ($ request ) : $ this ->resolveIndexAttributes ($ request ),
839839 'relationships ' => $ this ->when (value ($ related = $ this ->resolveRelationships ($ request )), $ related ),
@@ -846,7 +846,7 @@ public function serializeForIndex(RestifyRequest $request): array
846846 return $ this ->filter ([
847847 'id ' => $ this ->when ($ id = $ this ->getShowId ($ request ), $ id ),
848848 'type ' => $ this ->when ($ type = $ this ->getType ($ request ), $ type ),
849- 'attributes ' => $ this ->when ((bool )$ attrs = $ this ->resolveIndexAttributes ($ request ), $ attrs ),
849+ 'attributes ' => $ this ->when ((bool ) $ attrs = $ this ->resolveIndexAttributes ($ request ), $ attrs ),
850850 'relationships ' => $ this ->when (value ($ related = $ this ->resolveRelationships ($ request )), $ related ),
851851 'meta ' => $ this ->when (value ($ meta = $ this ->resolveIndexMeta ($ request )), $ meta ),
852852 ]);
@@ -896,12 +896,12 @@ protected static function fillBulkFields(RestifyRequest $request, Model $model,
896896
897897 public static function uriTo (Model $ model )
898898 {
899- return Restify::path () . '/ ' . static ::uriKey () . '/ ' . $ model ->getKey ();
899+ return Restify::path (). '/ ' . static ::uriKey (). '/ ' . $ model ->getKey ();
900900 }
901901
902902 public function availableFilters (RestifyRequest $ request )
903903 {
904- return collect ($ this ->filter ($ this ->filters ($ request )))->each (fn (Filter $ filter ) => $ filter ->authorizedToSee ($ request ))
904+ return collect ($ this ->filter ($ this ->filters ($ request )))->each (fn (Filter $ filter ) => $ filter ->authorizedToSee ($ request ))
905905 ->values ();
906906 }
907907
0 commit comments