ExportColumn::make('data')->label('Data')
->formatStateUsing(function ($state) {
// Debug log the incoming state
\Log::info('Data State:', ['state' => $state, 'type' => gettype($state)]);
if (is_null($state)) {
return json_encode([]);
}
// Keep it simple: just encode the data as JSON
if (is_array($state)) {
return json_encode($state);
}
// If it's already a JSON string, return it
if (is_string($state)) {
// Check if it's valid JSON
json_decode($state);
if (json_last_error() === JSON_ERROR_NONE) {
return $state;
}
}
// For other types, convert to string
return (string)$state;
}),
ExportColumn::make('data')->label('Data')
->formatStateUsing(function ($state) {
// Debug log the incoming state
\Log::info('Data State:', ['state' => $state, 'type' => gettype($state)]);
if (is_null($state)) {
return json_encode([]);
}
// Keep it simple: just encode the data as JSON
if (is_array($state)) {
return json_encode($state);
}
// If it's already a JSON string, return it
if (is_string($state)) {
// Check if it's valid JSON
json_decode($state);
if (json_last_error() === JSON_ERROR_NONE) {
return $state;
}
}
// For other types, convert to string
return (string)$state;
}),