mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +00:00
Rename controller namespaces: drop V1 prefix, clarify roles
V1/Admin -> Company (company-scoped controllers) V1/SuperAdmin -> Admin (platform-wide admin controllers) V1/Customer -> CustomerPortal (customer-facing portal) V1/Installation -> Setup (installation wizard) V1/PDF -> Pdf (consistent casing) V1/Modules -> Modules (drop V1 prefix) V1/Webhook -> Webhook (drop V1 prefix) The V1 prefix served no purpose - API versioning is in the route prefix (/api/v1/), not the controller namespace. "Admin" was misleading for company-scoped controllers. "SuperAdmin" is now simply "Admin" for platform administration.
This commit is contained in:
102
app/Http/Controllers/Admin/Update/UpdateController.php
Normal file
102
app/Http/Controllers/Admin/Update/UpdateController.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Update;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Setting;
|
||||
use App\Services\Update\Updater;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateController extends Controller
|
||||
{
|
||||
public function download(Request $request)
|
||||
{
|
||||
$this->authorize('manage update app');
|
||||
|
||||
$request->validate([
|
||||
'version' => 'required',
|
||||
]);
|
||||
|
||||
$path = Updater::download($request->version);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'path' => $path,
|
||||
]);
|
||||
}
|
||||
|
||||
public function unzip(Request $request)
|
||||
{
|
||||
$this->authorize('manage update app');
|
||||
|
||||
$request->validate([
|
||||
'path' => 'required',
|
||||
]);
|
||||
|
||||
try {
|
||||
$path = Updater::unzip($request->path);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'path' => $path,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'error' => $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function copyFiles(Request $request)
|
||||
{
|
||||
$this->authorize('manage update app');
|
||||
|
||||
$request->validate([
|
||||
'path' => 'required',
|
||||
]);
|
||||
|
||||
$path = Updater::copyFiles($request->path);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'path' => $path,
|
||||
]);
|
||||
}
|
||||
|
||||
public function migrate(Request $request)
|
||||
{
|
||||
$this->authorize('manage update app');
|
||||
|
||||
Updater::migrateUpdate();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function finishUpdate(Request $request)
|
||||
{
|
||||
$this->authorize('manage update app');
|
||||
|
||||
$request->validate([
|
||||
'installed' => 'required',
|
||||
'version' => 'required',
|
||||
]);
|
||||
|
||||
$json = Updater::finishUpdate($request->installed, $request->version);
|
||||
|
||||
return response()->json($json);
|
||||
}
|
||||
|
||||
public function checkLatestVersion(Request $request)
|
||||
{
|
||||
$this->authorize('manage update app');
|
||||
|
||||
set_time_limit(600); // 10 minutes
|
||||
|
||||
$json = Updater::checkForUpdate(Setting::getSetting('version'));
|
||||
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user