2023-10-04 07:58:39 +00:00
|
|
|
<?php
|
|
|
|
|
2023-12-07 18:06:32 +00:00
|
|
|
namespace App\Livewire\Project\Service;
|
2023-10-04 07:58:39 +00:00
|
|
|
|
|
|
|
use App\Models\LocalPersistentVolume;
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class Storage extends Component
|
|
|
|
{
|
|
|
|
protected $listeners = ['addNewVolume'];
|
|
|
|
public $resource;
|
|
|
|
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return view('livewire.project.service.storage');
|
|
|
|
}
|
|
|
|
public function addNewVolume($data)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
LocalPersistentVolume::create([
|
|
|
|
'name' => $data['name'],
|
|
|
|
'mount_path' => $data['mount_path'],
|
|
|
|
'host_path' => $data['host_path'],
|
|
|
|
'resource_id' => $this->resource->id,
|
|
|
|
'resource_type' => $this->resource->getMorphClass(),
|
|
|
|
]);
|
|
|
|
$this->resource->refresh();
|
2023-12-07 18:06:32 +00:00
|
|
|
$this->dispatch('success', 'Storage added successfully');
|
|
|
|
$this->dispatch('clearAddStorage');
|
|
|
|
$this->dispatch('refreshStorages');
|
2023-10-04 07:58:39 +00:00
|
|
|
} catch (\Throwable $e) {
|
|
|
|
return handleError($e, $this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|