coolify/app/Http/Livewire/Project/Shared/Storages/Show.php

50 lines
1.3 KiB
PHP
Raw Normal View History

2023-05-05 12:08:38 +02:00
<?php
2023-08-07 22:14:21 +02:00
namespace App\Http\Livewire\Project\Shared\Storages;
2023-05-05 12:08:38 +02:00
2023-09-22 11:23:49 +02:00
use App\Models\LocalPersistentVolume;
2023-05-05 12:08:38 +02:00
use Livewire\Component;
2023-07-13 13:16:24 +02:00
use Visus\Cuid2\Cuid2;
2023-05-05 12:08:38 +02:00
class Show extends Component
{
2023-09-22 11:23:49 +02:00
public LocalPersistentVolume $storage;
public bool $isReadOnly = false;
public ?string $modalId = null;
public ?string $realName = null;
2023-09-22 11:23:49 +02:00
2023-05-05 12:08:38 +02:00
protected $rules = [
'storage.name' => 'required|string',
'storage.mount_path' => 'required|string',
'storage.host_path' => 'string|nullable',
];
2023-06-16 12:35:40 +02:00
protected $validationAttributes = [
'name' => 'name',
'mount_path' => 'mount',
'host_path' => 'host',
];
2023-07-13 13:16:24 +02:00
public function mount()
{
if ($this->storage->resource_type === 'App\Models\ServiceApplication' || $this->storage->resource_type === 'App\Models\ServiceDatabase') {
$this->realName = "{$this->storage->service->service->uuid}_{$this->storage->name}";
} else {
$this->realName = $this->storage->name;
}
2023-07-13 13:16:24 +02:00
$this->modalId = new Cuid2(7);
}
2023-05-05 12:08:38 +02:00
public function submit()
{
$this->validate();
$this->storage->save();
2023-06-22 10:04:39 +02:00
$this->emit('success', 'Storage updated successfully');
2023-05-05 12:08:38 +02:00
}
2023-05-05 12:08:38 +02:00
public function delete()
{
$this->storage->delete();
$this->emit('refreshStorages');
}
}