'boolean', 'low_balance_alerts' => 'boolean', 'default_style' => 'array', ]; /** @return list */ public static function storableStyleKeys(): array { return [ 'foreground', 'background', 'error_correction', 'margin', 'module_style', 'finder_outer', 'finder_inner', 'frame_style', 'frame_text', 'frame_color', 'gradient_type', 'gradient_color1', 'gradient_color2', 'gradient_rotation', ]; } public function user(): BelongsTo { return $this->belongsTo(User::class); } public function resolvedDefaultType(): string { $type = (string) ($this->default_type ?? QrCode::TYPE_URL); return in_array($type, QrTypeCatalog::plusTypes(), true) ? $type : QrCode::TYPE_URL; } /** @return array */ public function resolvedDefaultStyle(): array { $stored = collect($this->default_style ?? []) ->only(self::storableStyleKeys()) ->filter(fn ($value) => $value !== null && $value !== '') ->all(); return QrStyleDefaults::merge($stored !== [] ? $stored : null); } /** @param array|null $input */ public static function sanitizeDefaultStyle(?array $input): ?array { if ($input === null) { return null; } $merged = QrStyleDefaults::merge( collect($input)->only(self::storableStyleKeys())->all(), ); return collect($merged)->only(self::storableStyleKeys())->all(); } }