2023-05-05 10:08:38 +00:00
|
|
|
<?php
|
|
|
|
|
2023-12-07 18:06:32 +00:00
|
|
|
namespace App\Livewire\Project\Shared\Storages;
|
2023-05-05 10:08:38 +00:00
|
|
|
|
2023-09-22 09:23:49 +00:00
|
|
|
use App\Models\LocalPersistentVolume;
|
2023-05-05 10:08:38 +00:00
|
|
|
use Livewire\Component;
|
2023-07-13 11:16:24 +00:00
|
|
|
use Visus\Cuid2\Cuid2;
|
2023-05-05 10:08:38 +00:00
|
|
|
|
|
|
|
class Show extends Component
|
|
|
|
{
|
2023-09-22 09:23:49 +00:00
|
|
|
public LocalPersistentVolume $storage;
|
|
|
|
public bool $isReadOnly = false;
|
|
|
|
public ?string $modalId = null;
|
2023-10-03 06:48:07 +00:00
|
|
|
public bool $isFirst = true;
|
2023-09-22 09:23:49 +00:00
|
|
|
|
2023-05-05 10:08:38 +00:00
|
|
|
protected $rules = [
|
|
|
|
'storage.name' => 'required|string',
|
|
|
|
'storage.mount_path' => 'required|string',
|
|
|
|
'storage.host_path' => 'string|nullable',
|
|
|
|
];
|
2023-06-16 10:35:40 +00:00
|
|
|
protected $validationAttributes = [
|
|
|
|
'name' => 'name',
|
|
|
|
'mount_path' => 'mount',
|
|
|
|
'host_path' => 'host',
|
|
|
|
];
|
2023-08-08 09:51:36 +00:00
|
|
|
|
2023-07-13 11:16:24 +00:00
|
|
|
public function mount()
|
|
|
|
{
|
|
|
|
$this->modalId = new Cuid2(7);
|
|
|
|
}
|
2023-08-08 09:51:36 +00:00
|
|
|
|
2023-05-05 10:08:38 +00:00
|
|
|
public function submit()
|
|
|
|
{
|
|
|
|
$this->validate();
|
|
|
|
$this->storage->save();
|
2023-12-07 18:06:32 +00:00
|
|
|
$this->dispatch('success', 'Storage updated successfully');
|
2023-05-05 10:08:38 +00:00
|
|
|
}
|
2023-08-08 09:51:36 +00:00
|
|
|
|
2023-05-05 10:08:38 +00:00
|
|
|
public function delete()
|
|
|
|
{
|
|
|
|
$this->storage->delete();
|
2024-04-17 09:32:35 +00:00
|
|
|
$this->dispatch('refresh_storages');
|
2023-05-05 10:08:38 +00:00
|
|
|
}
|
|
|
|
}
|