@@ -211,7 +211,7 @@ public static function newModel(): Model
211211
212212 public static function query (RestifyRequest $ request )
213213 {
214- if (!$ request ->isViaRepository ()) {
214+ if (! $ request ->isViaRepository ()) {
215215 return static ::newModel ()->query ();
216216 }
217217
@@ -276,8 +276,8 @@ public function collectFields(RestifyRequest $request)
276276
277277 if ($ this instanceof Mergeable) {
278278 $ fillable = collect ($ this ->resource ->getFillable ())
279- ->filter (fn ($ attribute ) => $ fields ->contains ('attribute ' , $ attribute ) === false )
280- ->map (fn ($ attribute ) => Field::new ($ attribute ));
279+ ->filter (fn ($ attribute ) => $ fields ->contains ('attribute ' , $ attribute ) === false )
280+ ->map (fn ($ attribute ) => Field::new ($ attribute ));
281281
282282 $ fields = $ fields ->merge ($ fillable );
283283 }
@@ -288,14 +288,14 @@ public function collectFields(RestifyRequest $request)
288288 private function indexFields (RestifyRequest $ request ): Collection
289289 {
290290 return $ this ->collectFields ($ request )
291- ->filter (fn (Field $ field ) => !$ field ->isHiddenOnIndex ($ request , $ this ))
291+ ->filter (fn (Field $ field ) => ! $ field ->isHiddenOnIndex ($ request , $ this ))
292292 ->values ();
293293 }
294294
295295 private function showFields (RestifyRequest $ request ): Collection
296296 {
297297 return $ this ->collectFields ($ request )
298- ->filter (fn (Field $ field ) => !$ field ->isHiddenOnShow ($ request , $ this ))
298+ ->filter (fn (Field $ field ) => ! $ field ->isHiddenOnShow ($ request , $ this ))
299299 ->values ();
300300 }
301301
@@ -409,10 +409,10 @@ public static function routes(Router $router, $attributes, $wrap = false)
409409 public function resolveShowAttributes (RestifyRequest $ request )
410410 {
411411 $ fields = $ this ->showFields ($ request )
412- ->filter (fn (Field $ field ) => $ field ->authorize ($ request ))
413- ->each (fn (Field $ field ) => $ field ->resolveForShow ($ this ))
414- ->map (fn (Field $ field ) => $ field ->serializeToValue ($ request ))
415- ->mapWithKeys (fn ($ value ) => $ value )
412+ ->filter (fn (Field $ field ) => $ field ->authorize ($ request ))
413+ ->each (fn (Field $ field ) => $ field ->resolveForShow ($ this ))
414+ ->map (fn (Field $ field ) => $ field ->serializeToValue ($ request ))
415+ ->mapWithKeys (fn ($ value ) => $ value )
416416 ->all ();
417417
418418 if ($ this instanceof Mergeable) {
@@ -430,7 +430,7 @@ public function resolveShowAttributes(RestifyRequest $request)
430430 return false ;
431431 }
432432
433- if (!$ field ->authorize ($ request )) {
433+ if (! $ field ->authorize ($ request )) {
434434 return false ;
435435 }
436436
@@ -451,10 +451,10 @@ public function resolveIndexAttributes($request)
451451 {
452452 // Resolve the show method, and attach the value to the array
453453 $ fields = $ this ->indexFields ($ request )
454- ->filter (fn (Field $ field ) => $ field ->authorize ($ request ))
455- ->each (fn (Field $ field ) => $ field ->resolveForIndex ($ this ))
456- ->map (fn (Field $ field ) => $ field ->serializeToValue ($ request ))
457- ->mapWithKeys (fn ($ value ) => $ value )
454+ ->filter (fn (Field $ field ) => $ field ->authorize ($ request ))
455+ ->each (fn (Field $ field ) => $ field ->resolveForIndex ($ this ))
456+ ->map (fn (Field $ field ) => $ field ->serializeToValue ($ request ))
457+ ->mapWithKeys (fn ($ value ) => $ value )
458458 ->all ();
459459
460460 if ($ this instanceof Mergeable) {
@@ -472,7 +472,7 @@ public function resolveIndexAttributes($request)
472472 return false ;
473473 }
474474
475- if (!$ field ->authorize ($ request )) {
475+ if (! $ field ->authorize ($ request )) {
476476 return false ;
477477 }
478478
@@ -518,7 +518,7 @@ public function resolveRelationships($request): array
518518 /** * @var AbstractPaginator $paginator */
519519 $ paginator = $ this ->resource ->{$ relation }()->take ($ request ->input ('relatablePerPage ' ) ?? (static ::$ defaultRelatablePerPage ?? RestifySearchable::DEFAULT_RELATABLE_PER_PAGE ))->get ();
520520
521- $ withs [$ relation ] = $ paginator ->map (fn (Model $ item ) => [
521+ $ withs [$ relation ] = $ paginator ->map (fn (Model $ item ) => [
522522 'attributes ' => $ item ->toArray (),
523523 ]);
524524 }
@@ -574,10 +574,10 @@ public function index(RestifyRequest $request)
574574
575575 return $ this ->response ([
576576 'meta ' => $ this ->resolveIndexMainMeta (
577- $ request , $ items ->map (fn (self $ repository ) => $ repository ->resource ), RepositoryCollection::meta ($ paginator ->toArray ())
577+ $ request , $ items ->map (fn (self $ repository ) => $ repository ->resource ), RepositoryCollection::meta ($ paginator ->toArray ())
578578 ) ?? RepositoryCollection::meta ($ paginator ->toArray ()),
579579 'links ' => RepositoryCollection::paginationLinks ($ paginator ->toArray ()),
580- 'data ' => $ items ->map (fn (self $ repository ) => $ repository ->serializeForIndex ($ request )),
580+ 'data ' => $ items ->map (fn (self $ repository ) => $ repository ->serializeForIndex ($ request )),
581581 ]);
582582 }
583583
@@ -609,7 +609,7 @@ public function store(RestifyRequest $request)
609609 $ this ->resource ->save ();
610610 }
611611
612- $ this ->storeFields ($ request )->each (fn (Field $ field ) => $ field ->invokeAfter ($ request , $ this ->resource ));
612+ $ this ->storeFields ($ request )->each (fn (Field $ field ) => $ field ->invokeAfter ($ request , $ this ->resource ));
613613 });
614614
615615 static ::stored ($ this ->resource , $ request );
@@ -633,7 +633,7 @@ public function storeBulk(RepositoryStoreBulkRequest $request)
633633
634634 $ this ->resource ->save ();
635635
636- $ this ->storeBulkFields ($ request )->each (fn (Field $ field ) => $ field ->invokeAfter ($ request , $ this ->resource ));
636+ $ this ->storeBulkFields ($ request )->each (fn (Field $ field ) => $ field ->invokeAfter ($ request , $ this ->resource ));
637637
638638 return $ this ->resource ;
639639 });
@@ -680,8 +680,8 @@ public function updateBulk(RestifyRequest $request, $repositoryId, int $row)
680680 public function attach (RestifyRequest $ request , $ repositoryId , Collection $ pivots )
681681 {
682682 DB ::transaction (function () use ($ request , $ pivots ) {
683- return $ pivots ->map (fn ($ pivot ) => $ pivot ->forceFill ($ request ->except ($ request ->relatedRepository )))
684- ->map (fn ($ pivot ) => $ pivot ->save ());
683+ return $ pivots ->map (fn ($ pivot ) => $ pivot ->forceFill ($ request ->except ($ request ->relatedRepository )))
684+ ->map (fn ($ pivot ) => $ pivot ->save ());
685685 });
686686
687687 return $ this ->response ()
@@ -691,8 +691,8 @@ public function attach(RestifyRequest $request, $repositoryId, Collection $pivot
691691
692692 public function detach (RestifyRequest $ request , $ repositoryId , Collection $ pivots )
693693 {
694- $ deleted = DB ::transaction (function () use ($ request , $ pivots ) {
695- return $ pivots ->map (fn ($ pivot ) => $ pivot ->delete ());
694+ $ deleted = DB ::transaction (function () use ($ pivots ) {
695+ return $ pivots ->map (fn ($ pivot ) => $ pivot ->delete ());
696696 });
697697
698698 return $ this ->response ()
@@ -802,7 +802,7 @@ public function response($content = '', $status = 200, array $headers = []): Res
802802 public function serializeForShow (RestifyRequest $ request ): array
803803 {
804804 return $ this ->filter ([
805- 'id ' => $ this ->when ($ this ->resource ->id , fn () => $ this ->getShowId ($ request )),
805+ 'id ' => $ this ->when ($ this ->resource ->id , fn () => $ this ->getShowId ($ request )),
806806 'type ' => $ this ->when ($ type = $ this ->getType ($ request ), $ type ),
807807 'attributes ' => $ request ->isShowRequest () ? $ this ->resolveShowAttributes ($ request ) : $ this ->resolveIndexAttributes ($ request ),
808808 'relationships ' => $ this ->when (value ($ related = $ this ->resolveRelationships ($ request )), $ related ),
@@ -815,7 +815,7 @@ public function serializeForIndex(RestifyRequest $request): array
815815 return $ this ->filter ([
816816 'id ' => $ this ->when ($ id = $ this ->getShowId ($ request ), $ id ),
817817 'type ' => $ this ->when ($ type = $ this ->getType ($ request ), $ type ),
818- 'attributes ' => $ this ->when ((bool )$ attrs = $ this ->resolveIndexAttributes ($ request ), $ attrs ),
818+ 'attributes ' => $ this ->when ((bool ) $ attrs = $ this ->resolveIndexAttributes ($ request ), $ attrs ),
819819 'relationships ' => $ this ->when (value ($ related = $ this ->resolveRelationships ($ request )), $ related ),
820820 'meta ' => $ this ->when (value ($ meta = $ this ->resolveIndexMeta ($ request )), $ meta ),
821821 ]);
@@ -865,12 +865,12 @@ protected static function fillBulkFields(RestifyRequest $request, Model $model,
865865
866866 public static function uriTo (Model $ model )
867867 {
868- return Restify::path () . '/ ' . static ::uriKey () . '/ ' . $ model ->getKey ();
868+ return Restify::path (). '/ ' . static ::uriKey (). '/ ' . $ model ->getKey ();
869869 }
870870
871871 public function availableFilters (RestifyRequest $ request )
872872 {
873- return collect ($ this ->filter ($ this ->filters ($ request )))->each (fn (Filter $ filter ) => $ filter ->authorizedToSee ($ request ))
873+ return collect ($ this ->filter ($ this ->filters ($ request )))->each (fn (Filter $ filter ) => $ filter ->authorizedToSee ($ request ))
874874 ->values ();
875875 }
876876
0 commit comments