mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-02 05:10:59 +00:00
* refactor: stabilize model identities for domain migration * refactor: extract module platform context * refactor: assign models to domain contexts * refactor: extract ai platform context * refactor: extract storage platform context * refactor: extract mail platform context * refactor: extract pdf platform context * refactor: extract operations platform context * refactor: move installation into operations platform * refactor: extract money domain context * refactor: extract taxation domain context * refactor: extract catalog domain context * refactor: extract metadata domain context * refactor: extract reporting domain context * refactor: extract purchases domain context * refactor: extract receivables domain context * refactor: extract accounts domain context * refactor: complete reporting statement boundary * refactor: extract contacts domain context * refactor: extract sales domain context * refactor: remove legacy application layers * fix: migrate legacy bouncer role identities
117 lines
3.0 KiB
PHP
117 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Platform\Operations\Http\Admin;
|
|
|
|
use App\Platform\Http\Controller;
|
|
use App\Platform\Operations\Update\Updater;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
class UpdateController extends Controller
|
|
{
|
|
public function checkVersion(Request $request): JsonResponse
|
|
{
|
|
$this->ensureSuperAdmin();
|
|
|
|
set_time_limit(600);
|
|
|
|
$channel = $request->get('channel', 'stable');
|
|
$version = preg_replace('~[\r\n]+~', '', File::get(base_path('version.md')));
|
|
|
|
return response()->json(Updater::checkForUpdate($version, $channel));
|
|
}
|
|
|
|
public function download(Request $request): JsonResponse
|
|
{
|
|
$this->ensureSuperAdmin();
|
|
|
|
$request->validate(['version' => 'required']);
|
|
|
|
return response()->json([
|
|
'success' => true,
|
|
'path' => Updater::download($request->version),
|
|
]);
|
|
}
|
|
|
|
public function unzip(Request $request): JsonResponse
|
|
{
|
|
$this->ensureSuperAdmin();
|
|
|
|
$request->validate(['path' => 'required']);
|
|
|
|
try {
|
|
return response()->json([
|
|
'success' => true,
|
|
'path' => Updater::unzip($request->path),
|
|
]);
|
|
} catch (\Exception $e) {
|
|
return response()->json([
|
|
'success' => false,
|
|
'error' => $e->getMessage(),
|
|
], 500);
|
|
}
|
|
}
|
|
|
|
public function copy(Request $request): JsonResponse
|
|
{
|
|
$this->ensureSuperAdmin();
|
|
|
|
$request->validate(['path' => 'required']);
|
|
|
|
return response()->json([
|
|
'success' => true,
|
|
'path' => Updater::copyFiles($request->path),
|
|
]);
|
|
}
|
|
|
|
public function delete(Request $request): JsonResponse
|
|
{
|
|
return $this->clean($request);
|
|
}
|
|
|
|
public function clean(Request $request): JsonResponse
|
|
{
|
|
$this->ensureSuperAdmin();
|
|
|
|
// Backward compatibility: use deleted_files when no manifest exists
|
|
if (! File::exists(base_path('manifest.json'))
|
|
&& isset($request->deleted_files)
|
|
&& ! empty($request->deleted_files)) {
|
|
Updater::deleteFiles($request->deleted_files);
|
|
|
|
return response()->json(['success' => true, 'cleaned' => 0]);
|
|
}
|
|
|
|
$result = Updater::cleanStaleFiles();
|
|
|
|
return response()->json($result);
|
|
}
|
|
|
|
public function migrate(Request $request): JsonResponse
|
|
{
|
|
$this->ensureSuperAdmin();
|
|
|
|
Updater::migrateUpdate();
|
|
|
|
return response()->json(['success' => true]);
|
|
}
|
|
|
|
public function finish(Request $request): JsonResponse
|
|
{
|
|
$this->ensureSuperAdmin();
|
|
|
|
$request->validate([
|
|
'installed' => 'required',
|
|
'version' => 'required',
|
|
]);
|
|
|
|
return response()->json(Updater::finishUpdate($request->installed, $request->version));
|
|
}
|
|
|
|
private function ensureSuperAdmin(): void
|
|
{
|
|
$this->authorize('manage update app');
|
|
}
|
|
}
|