@@ -118,43 +118,6 @@ public function form(Form $form): Form
118118 ]);
119119 }
120120
121- private function formatCustomFields (array $ fields ): array
122- {
123- return collect ($ fields )->mapWithKeys (function ($ field , $ key ) {
124- $ parts = explode ('\\' , $ field );
125- $ lastPart = end ($ parts );
126- $ formattedName = Str::title (Str::snake ($ lastPart , ' ' ));
127-
128- return [$ key => $ formattedName ];
129- })->toArray ();
130- }
131-
132- private function initializeDefaultConfig (string $ fieldType ): array
133- {
134- $ className = 'Backstage \\Fields \\Fields \\' . Str::studly ($ fieldType );
135-
136- if (! class_exists ($ className )) {
137- return [];
138- }
139-
140- $ fieldInstance = app ($ className );
141-
142- return $ fieldInstance ::getDefaultConfig ();
143- }
144-
145- private function initializeCustomConfig (string $ fieldType ): array
146- {
147- $ className = Fields::getFields ()[$ fieldType ] ?? null ;
148-
149- if (! class_exists ($ className )) {
150- return [];
151- }
152-
153- $ fieldInstance = app ($ className );
154-
155- return $ fieldInstance ::getDefaultConfig ();
156- }
157-
158121 public function table (Table $ table ): Table
159122 {
160123 return $ table
@@ -185,13 +148,13 @@ public function table(Table $table): Table
185148 ->slideOver ()
186149 ->mutateFormDataUsing (function (array $ data ) {
187150
188- $ key = $ this ->ownerRecord ->getKeyName () ?? ' id ' ;
151+ $ key = $ this ->ownerRecord ->getKeyName ();
189152
190153 return [
191154 ...$ data ,
192155 'position ' => Field::where ('model_key ' , $ key )->get ()->max ('position ' ) + 1 ,
193156 'model_type ' => 'setting ' ,
194- 'model_key ' => $ this ->ownerRecord ->slug ,
157+ 'model_key ' => $ this ->ownerRecord ->getKey () ,
195158 ];
196159 })
197160 ->after (function (Component $ livewire ) {
@@ -203,7 +166,7 @@ public function table(Table $table): Table
203166 ->slideOver ()
204167 ->mutateRecordDataUsing (function (array $ data ) {
205168
206- $ key = $ this ->ownerRecord ->getKeyName () ?? ' id ' ;
169+ $ key = $ this ->ownerRecord ->getKeyName ();
207170
208171 return [
209172 ...$ data ,
@@ -222,7 +185,7 @@ public function table(Table $table): Table
222185 ->hasColumn ($ this ->ownerRecord ->getTable (), $ record ->valueColumn )
223186 ) {
224187
225- $ key = $ this ->ownerRecord ->getKeyName () ?? ' id ' ;
188+ $ key = $ this ->ownerRecord ->getKeyName ();
226189
227190 $ this ->ownerRecord ->update ([
228191 $ record ->valueColumn => collect ($ this ->ownerRecord ->{$ record ->valueColumn })->forget ($ record ->{$ key })->toArray (),
0 commit comments