How do I count the saved elements of a form's Repeater Field in a table column?

In my form I have a Repeater field which saves data as json (cast to array in model). Now I want to show the count of these items from this json column in my table, for example with a TextColumn. How do I achieve that?

If I try with
formatStateUsing...
I always get the error
Array to string conversion
, no matter what I try .
Solution
Maybe try getStateUsing? You should then be able to use a different column name, which doesn't have to exist on the table, and do whatever you need based on the $record ...

TextColumn::make('yourjson_count')
  ->getStateUsing(Model $record) => count($record->yourjson')),
Was this page helpful?