diff --git a/src/Http/Controllers/BackupStatusesController.php b/src/Http/Controllers/BackupStatusesController.php index 7195cf6..8aa92eb 100644 --- a/src/Http/Controllers/BackupStatusesController.php +++ b/src/Http/Controllers/BackupStatusesController.php @@ -12,7 +12,7 @@ class BackupStatusesController extends ApiController public function index() { return Cache::remember('backup-statuses', now()->addSeconds(4), function () { - return BackupDestinationStatusFactory::createForMonitorConfig(config('backup.monitor_backups')) + return BackupDestinationStatusFactory::createForMonitorConfig($this->getMonitorConfig()) ->map(function (BackupDestinationStatus $backupDestinationStatus) { return [ 'name' => $backupDestinationStatus->backupDestination()->backupName(), @@ -30,4 +30,20 @@ public function index() ->toArray(); }); } + + /** + * Get monitor configuration data. + * spatie/laravel-backup ^9.x introduce DTO parameter instead of array. + * + * @return \Spatie\Backup\Config\MonitoredBackupsConfig|array + */ + protected function getMonitorConfig() + { + $reflection = new \ReflectionMethod(BackupDestinationStatusFactory::class, 'createForMonitorConfig'); + $monitorBackupsType = $reflection->getParameters()[0]->getType()->getName(); + + return $monitorBackupsType === 'Spatie\Backup\Config\MonitoredBackupsConfig' + ? \Spatie\Backup\Config\MonitoredBackupsConfig::fromArray(config('backup.monitor_backups')) + : config('backup.monitor_backups'); + } }