feat: patient view, media player, and rich editor enhancements
This commit is contained in:
+9
-19
@@ -8,7 +8,7 @@
|
||||
if (in_array($locale, config('app.available_locales', ['fa', 'en']))) {
|
||||
session(['locale' => $locale]);
|
||||
}
|
||||
return redirect()->back();
|
||||
return redirect(url()->previous('/admin'));
|
||||
})->name('locale.switch');
|
||||
|
||||
Route::middleware(['web', 'auth'])->group(function () {
|
||||
@@ -40,27 +40,17 @@
|
||||
})->name('sync.run');
|
||||
|
||||
Route::get('/admin/backup/download', function () {
|
||||
$dbPath = database_path('database.sqlite');
|
||||
$zipPath = session('backup_tmp_path');
|
||||
$zipName = session('backup_tmp_name', 'matab-backup.zip');
|
||||
|
||||
if (! file_exists($dbPath)) {
|
||||
abort(404, 'Database file not found.');
|
||||
if (! $zipPath || ! file_exists($zipPath)) {
|
||||
abort(404, 'Backup file not found.');
|
||||
}
|
||||
|
||||
$backupDir = storage_path('app/backups');
|
||||
session()->forget(['backup_tmp_path', 'backup_tmp_name']);
|
||||
|
||||
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]);
|
||||
return response()->download($zipPath, $zipName, [
|
||||
'Content-Type' => 'application/zip',
|
||||
])->deleteFileAfterSend(true);
|
||||
})->name('backup.download');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user