feat: add lab tests, patient file management, and prescription improvements

This commit is contained in:
SajjadMahmoody
2026-04-17 20:15:38 +03:30
parent 6a301c5529
commit bf0ada051f
53 changed files with 3201 additions and 387 deletions
+22 -9
View File
@@ -40,14 +40,27 @@
})->name('sync.run');
Route::get('/admin/backup/download', function () {
$data = [
'exported_at' => now()->toDateTimeString(),
'last_sync_id' => \App\Models\SyncLog::lastSyncId(),
'changes' => \App\Models\SyncLog::all()->toArray(),
];
$filename = 'matab-backup-' . now()->format('Y-m-d_H-i-s') . '.json';
return response()->streamDownload(function () use ($data) {
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}, $filename, ['Content-Type' => 'application/json']);
$dbPath = database_path('database.sqlite');
if (! file_exists($dbPath)) {
abort(404, 'Database file not found.');
}
$backupDir = storage_path('app/backups');
if (! is_dir($backupDir)) {
mkdir($backupDir, 0755, true);
}
foreach (glob($backupDir . '/matab-backup-*.sqlite') as $oldFile) {
unlink($oldFile);
}
$filename = 'matab-backup-' . now()->format('Y-m-d_H-i-s') . '.sqlite';
$backupPath = $backupDir . '/' . $filename;
copy($dbPath, $backupPath);
return response()->json(['success' => true, 'filename' => $filename]);
})->name('backup.download');
});