2024-04-26 12:09:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Livewire\Storage;
|
|
|
|
|
|
|
|
|
|
use App\Models\S3Storage;
|
2026-03-19 10:42:29 +00:00
|
|
|
use App\Models\ScheduledDatabaseBackup;
|
2025-11-17 09:05:18 +00:00
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
2024-04-26 12:09:54 +00:00
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
|
|
class Show extends Component
|
|
|
|
|
{
|
2025-11-17 09:05:18 +00:00
|
|
|
use AuthorizesRequests;
|
|
|
|
|
|
2024-04-26 12:09:54 +00:00
|
|
|
public $storage = null;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2026-03-19 10:42:29 +00:00
|
|
|
public string $currentRoute = '';
|
|
|
|
|
|
|
|
|
|
public int $backupCount = 0;
|
|
|
|
|
|
2024-04-26 12:09:54 +00:00
|
|
|
public function mount()
|
|
|
|
|
{
|
|
|
|
|
$this->storage = S3Storage::ownedByCurrentTeam()->whereUuid(request()->storage_uuid)->first();
|
2024-06-10 20:43:34 +00:00
|
|
|
if (! $this->storage) {
|
2024-04-26 12:09:54 +00:00
|
|
|
abort(404);
|
|
|
|
|
}
|
2025-11-17 09:05:18 +00:00
|
|
|
$this->authorize('view', $this->storage);
|
2026-03-19 10:42:29 +00:00
|
|
|
$this->currentRoute = request()->route()->getName();
|
|
|
|
|
$this->backupCount = ScheduledDatabaseBackup::where('s3_storage_id', $this->storage->id)->count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function delete()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$this->authorize('delete', $this->storage);
|
|
|
|
|
|
|
|
|
|
$this->storage->delete();
|
|
|
|
|
|
|
|
|
|
return redirect()->route('storage.index');
|
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
|
return handleError($e, $this);
|
|
|
|
|
}
|
2024-04-26 12:09:54 +00:00
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-04-26 12:09:54 +00:00
|
|
|
public function render()
|
|
|
|
|
{
|
|
|
|
|
return view('livewire.storage.show');
|
|
|
|
|
}
|
|
|
|
|
}
|