attributes['data'] = json_encode($value); } else { $this->attributes['data'] = $value; } } public function getDataAttribute($value) { $decoded = json_decode($value, true); if ($decoded && is_array($decoded)) { return $decoded; } return []; } }