style updates

This commit is contained in:
Mark Gregory
2026-07-24 14:59:44 +01:00
parent 24ab771cd3
commit dd23205d0b
482 changed files with 7173 additions and 1435 deletions
+15 -5
View File
@@ -1,4 +1,5 @@
<?php
namespace Modules\Enterprise\Services;
use Illuminate\Support\Facades\File;
@@ -11,15 +12,19 @@ final class BackupService
{
public function create(?int $userId = null): Backup
{
if (! class_exists(ZipArchive::class)) throw new RuntimeException('The PHP zip extension is required.');
if (! class_exists(ZipArchive::class)) {
throw new RuntimeException('The PHP zip extension is required.');
}
$disk = (string) config('enterprise.backup_disk', 'local');
$directory = trim((string) config('enterprise.backup_path', 'backups'), '/');
$name = 'cms-'.now()->format('Ymd-His').'.zip';
$relativePath = $directory.'/'.$name;
$temporary = storage_path('app/'.$name);
$zip = new ZipArchive();
if ($zip->open($temporary, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== true) throw new RuntimeException('Unable to create backup archive.');
$zip = new ZipArchive;
if ($zip->open($temporary, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== true) {
throw new RuntimeException('Unable to create backup archive.');
}
$manifest = json_encode([
'application' => config('app.name'),
@@ -30,10 +35,14 @@ final class BackupService
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
$zip->addFromString('manifest.json', $manifest ?: '{}');
$zip->addFile(base_path('composer.json'), 'composer.json');
if (File::exists(base_path('modules_statuses.json'))) $zip->addFile(base_path('modules_statuses.json'), 'modules_statuses.json');
if (File::exists(base_path('modules_statuses.json'))) {
$zip->addFile(base_path('modules_statuses.json'), 'modules_statuses.json');
}
if (config('database.default') === 'sqlite') {
$database = database_path('database.sqlite');
if (File::exists($database)) $zip->addFile($database, 'database/database.sqlite');
if (File::exists($database)) {
$zip->addFile($database, 'database/database.sqlite');
}
}
$zip->close();
@@ -61,6 +70,7 @@ final class BackupService
$cutoff = now()->subDays((int) config('enterprise.retention_days', 30));
$backups = Backup::query()->where('created_at', '<', $cutoff)->get();
$backups->each(fn (Backup $backup) => $this->delete($backup));
return $backups->count();
}
}