initial commit
This commit is contained in:
55
app/Http/Controllers/Web/VmSnapshotController.php
Normal file
55
app/Http/Controllers/Web/VmSnapshotController.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Customer;
|
||||
use App\Models\VmSnapshot;
|
||||
use App\Services\Hosting\Snapshots\SnapshotService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class VmSnapshotController extends Controller
|
||||
{
|
||||
public function store(Request $request, Customer $vm, SnapshotService $snapshots): RedirectResponse
|
||||
{
|
||||
$this->authorize('manage', $vm);
|
||||
$request->validate(['label' => ['nullable', 'string', 'max:64']]);
|
||||
|
||||
try {
|
||||
$snapshots->create($vm, $request->user(), false, $request->input('label'));
|
||||
} catch (\Throwable $e) {
|
||||
return back()->withErrors(['snapshot' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
return back()->with('success', 'Snapshot erstellt.');
|
||||
}
|
||||
|
||||
public function rollback(Customer $vm, VmSnapshot $snapshot, SnapshotService $snapshots): RedirectResponse
|
||||
{
|
||||
$this->authorize('manage', $vm);
|
||||
abort_unless($snapshot->customer_id === $vm->id, 404);
|
||||
|
||||
try {
|
||||
$snapshots->rollback($vm, $snapshot);
|
||||
} catch (\Throwable $e) {
|
||||
return back()->withErrors(['snapshot' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
return back()->with('success', 'Snapshot wiederhergestellt.');
|
||||
}
|
||||
|
||||
public function destroy(Customer $vm, VmSnapshot $snapshot, SnapshotService $snapshots): RedirectResponse
|
||||
{
|
||||
$this->authorize('manage', $vm);
|
||||
abort_unless($snapshot->customer_id === $vm->id, 404);
|
||||
|
||||
try {
|
||||
$snapshots->delete($vm, $snapshot);
|
||||
} catch (\Throwable $e) {
|
||||
return back()->withErrors(['snapshot' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
return back()->with('success', 'Snapshot gelöscht.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user