'array', 'is_active' => 'boolean', 'sync_interval_minutes' => 'integer', 'last_sync_at' => 'datetime', 'last_error_at' => 'datetime', 'ordine' => 'integer', ]; public function scopeAttivi($query) { return $query->where('is_active', true)->orderBy('ordine'); } public function getDecryptedConfig(): array { $config = $this->config; foreach (['username', 'password', 'client_secret', 'refresh_token', 'api_key'] as $field) { if (isset($config[$field])) { try { $config[$field] = Crypt::decryptString($config[$field]); } catch (\Exception) { } } } return $config; } public function encryptAndSetConfig(array $config): void { foreach (['username', 'password', 'client_secret', 'refresh_token', 'api_key'] as $field) { if (isset($config[$field]) && $config[$field] !== '' && !str_starts_with($config[$field], 'eyJpdiI')) { $config[$field] = Crypt::encryptString($config[$field]); } } $this->config = $config; } public static function opzioniTipo(): array { return ['google_calendar', 'caldav']; } public static function etichettaTipo(string $tipo): string { return match ($tipo) { 'google_calendar' => 'Google Calendar', 'caldav' => 'CalDAV (Infomaniak/NextCloud)', default => ucfirst($tipo), }; } }