Table Colum Json - Array to string conversion error
in user table there is a settings column that is json.
Tables\Columns\TextColumn::make('settings')
throws Array to string conversion.
formatStateUsing
- throws array to string conversion error
Tried to cast in user model as
protected $cast = [ 'settings' => array ]
Also throws array to string conversion error
Could not find anything in table builder docs. Not a single mention.
I am pretty sure that there is some way to do it, and wondering how as it is not possible that is not possible π
Anyone can help?6 Replies
That's because you cannot print array as string. What do you want to do with that json? Just to print json string in a column?
yes
What is you settings column type? JSON?
Basically it should work like the example below. Just remove settings => array from casts.
thank you for your reply. in my first line i described it and show code example as same as you tried to help.
i agree that 'should' work. the thing is that from some reason, unknown to me, just does not. π
there was no array in casts before . i added it trying to find a workable solution.
However, i think i will try diffrent approach and make a custom table column, so i can do other things with settings too. I think that would be a good idea.
Thank you, again π
you could just json encode then
in the formatstateusing
if you want to print the whole json
Look at spatie settings π