F
Filament7mo ago
nighty

Repeater - Array to String Conversion when save - logImplodeAssoc

i am on my first testing to store json arrays into database with repeater. - the database column was changed to JSON with a migration - the Model got: protected $casts = ['urls' => 'json']; - output is also working but a related error message will be thown when saving the form - i am not sure if i am doing something wrong, or it´s a bug: Array to string conversion /** * Format an assoc array as a key/value string for logging * @return string */ public static function logImplodeAssoc(array $attrs): string { $l = ''; foreach( $attrs as $k => $v ) { ** $l .= "{ $k => $v } ";** } return $l; } Repeater: Repeater::make('urls')->schema([ TextInput::make('Stream-URL') ]) ->hidden(function(Get $get){ if(!in_array($get('type'),[9,7,11,10])){ return true; } return false; }), TextColumn: TextColumn::make('outstream.urls')->state(function(Model $record){ $out = ''; foreach((array)$record->outipstream->urls as $url){ $out .= $url['Stream-URL'].' '; } return $out; }),
Solution:
it says that function is in app/Traits/Observable.php, that is in your app, not filament or laravel.
Jump to solution
5 Replies
slamx_
slamx_7mo ago
Can you share your error message?
nighty
nightyOP7mo ago
nighty
nightyOP7mo ago
the error happens in the function logImplodeAssoc which is not my code ... its from filament or laravel i figured out something..... the error occurs in observable.php if i change the function this way, the error is gone: /** * Format an assoc array as a key/value string for logging * @return string */ public static function logImplodeAssoc(array $attrs): string { $l = ''; foreach( $attrs as $k => $v ) { /* changes Start */ if(is_array($v)){ continue; } /* change End */ $l .= "{ $k => $v } "; } return $l; } when converting the array for logging ... it converts only one level - if multidimensional array comes to this function it breaks - i think it has to be fixed in filament source
Solution
awcodes
awcodes7mo ago
it says that function is in app/Traits/Observable.php, that is in your app, not filament or laravel.
nighty
nightyOP7mo ago
i share this project with other developers.... i wasn´t aware, that it´s not from laravel... thanks for the hint
Want results from more Discord servers?
Add your server