File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change 44
55namespace Webfox \InertiaDataProviders ;
66
7- use Illuminate \Contracts \Support \Arrayable ;
8- use Illuminate \Contracts \Support \Jsonable ;
7+ use ReflectionClass ;
98use Inertia \LazyProp ;
109use Inertia \Response ;
11- use ReflectionClass ;
1210use ReflectionMethod ;
13- use ReflectionNamedType ;
1411use ReflectionProperty ;
12+ use ReflectionNamedType ;
13+ use Illuminate \Contracts \Support \Jsonable ;
1514use Symfony \Component \VarDumper \VarDumper ;
15+ use Illuminate \Contracts \Support \Arrayable ;
16+ use Webfox \InertiaDataProviders \AttributeNameFormatters \AttributeNameFormatter ;
1617
1718abstract class DataProvider implements Arrayable, Jsonable
1819{
@@ -47,7 +48,12 @@ public function toArray(): array
4748 return [$ method ->name => fn () => app ()->call ([$ this , $ method ->name ])];
4849 });
4950
50- return collect ()->merge ($ staticData )->merge ($ convertedProperties )->merge ($ convertedMethods )->toArray ();
51+ return collect ()
52+ ->merge ($ staticData )
53+ ->merge ($ convertedProperties )
54+ ->merge ($ convertedMethods )
55+ ->mapWithKeys (fn ($ value , $ key ) => [$ this ->attributeNameFormatter ()($ key ) => $ value ])
56+ ->toArray ();
5157 }
5258
5359 public function toNestedArray (): array
@@ -75,4 +81,9 @@ public function dd()
7581 $ this ->dump ();
7682 exit (1 );
7783 }
84+
85+ protected function attributeNameFormatter (): AttributeNameFormatter
86+ {
87+ return app ()->make (config ('inertia-dataproviders.attribute_name_formatter ' ));
88+ }
7889}
You can’t perform that action at this time.
0 commit comments