66use Backstage \Fields \Concerns \HasFieldTypeResolver ;
77use Backstage \Fields \Concerns \HasOptions ;
88use Backstage \Fields \Contracts \FieldContract ;
9+ use Backstage \Fields \Contracts \HydratesValues ;
910use Backstage \Fields \Enums \Field as FieldEnum ;
1011use Backstage \Fields \Facades \Fields ;
1112use Backstage \Fields \Models \Field ;
2122use Filament \Schemas \Components \Tabs \Tab ;
2223use Filament \Schemas \Components \Utilities \Get ;
2324use Filament \Schemas \Components \Utilities \Set ;
25+ use Illuminate \Database \Eloquent \Model ;
2426use Illuminate \Support \Collection ;
2527use Illuminate \Support \Str ;
2628use Saade \FilamentAdjacencyList \Forms \Components \AdjacencyList ;
2729
28- use Backstage \Fields \Contracts \HydratesValues ;
29- use Illuminate \Database \Eloquent \Model ;
30-
3130class Repeater extends Base implements FieldContract, HydratesValues
3231{
3332 use HasConfigurableFields;
@@ -47,13 +46,14 @@ public function hydrate(mixed $value, ?Model $model = null): mixed
4746
4847 if (empty ($ this ->field_model )) {
4948 file_put_contents ('/tmp/repeater_debug.log ' , "Field model missing for repeater. \n" , FILE_APPEND );
49+
5050 return $ value ;
5151 }
5252
5353 $ children = $ this ->field_model ->children ->keyBy ('ulid ' );
5454 $ slugMap = $ this ->field_model ->children ->pluck ('ulid ' , 'slug ' );
5555
56- file_put_contents ('/tmp/repeater_debug.log ' , " Hydrating Repeater " . $ this ->field_model ->ulid . " with children slugs: " . implode (', ' , $ slugMap ->keys ()->toArray ()) . "\n" , FILE_APPEND );
56+ file_put_contents ('/tmp/repeater_debug.log ' , ' Hydrating Repeater ' . $ this ->field_model ->ulid . ' with children slugs: ' . implode (', ' , $ slugMap ->keys ()->toArray ()) . "\n" , FILE_APPEND );
5757
5858 $ hydrated = [];
5959
@@ -66,19 +66,19 @@ public function hydrate(mixed $value, ?Model $model = null): mixed
6666 if ($ fieldUlid && isset ($ children [$ fieldUlid ])) {
6767 $ fieldModel = $ children [$ fieldUlid ];
6868 $ fieldClass = self ::resolveFieldTypeClassName ($ fieldModel ->field_type );
69-
69+
7070 file_put_contents ('/tmp/repeater_debug.log ' , " > Hydrating field $ fieldSlug ( $ fieldModel ->field_type ) using $ fieldClass \n" , FILE_APPEND );
7171
7272 if ($ fieldClass && in_array (HydratesValues::class, class_implements ($ fieldClass ))) {
7373 // Instantiate the field class to access its hydrate method
74- // We need to set the field model on the instance if possible,
74+ // We need to set the field model on the instance if possible,
7575 // or at least pass context if needed.
7676 // Assuming simpler 'make' or instantiation works for hydration context.
77- $ fieldInstance = new $ fieldClass() ;
77+ $ fieldInstance = new $ fieldClass ;
7878 if (property_exists ($ fieldInstance , 'field_model ' )) {
7979 $ fieldInstance ->field_model = $ fieldModel ;
8080 }
81-
81+
8282 $ hydratedRow [$ fieldSlug ] = $ fieldInstance ->hydrate ($ fieldValue , $ model );
8383 }
8484 }
0 commit comments