2023-05-05 10:08:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Livewire\Project\Application\Storages;
|
|
|
|
|
|
|
|
use App\Models\Application;
|
2023-05-05 12:20:10 +00:00
|
|
|
use App\Models\LocalPersistentVolume;
|
2023-05-05 10:08:38 +00:00
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class All extends Component
|
|
|
|
{
|
|
|
|
public Application $application;
|
2023-05-05 12:20:10 +00:00
|
|
|
protected $listeners = ['refreshStorages', 'submit'];
|
2023-05-05 10:08:38 +00:00
|
|
|
public function refreshStorages()
|
|
|
|
{
|
|
|
|
$this->application->refresh();
|
|
|
|
}
|
2023-05-05 12:20:10 +00:00
|
|
|
public function submit($data)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
LocalPersistentVolume::create([
|
|
|
|
'name' => $data['name'],
|
|
|
|
'mount_path' => $data['mount_path'],
|
|
|
|
'host_path' => $data['host_path'],
|
|
|
|
'resource_id' => $this->application->id,
|
|
|
|
'resource_type' => Application::class,
|
|
|
|
]);
|
|
|
|
$this->application->refresh();
|
|
|
|
$this->emit('clearAddStorage');
|
|
|
|
} catch (\Exception $e) {
|
2023-05-09 09:33:50 +00:00
|
|
|
return generalErrorHandler($e, $this);
|
2023-05-05 12:20:10 +00:00
|
|
|
}
|
|
|
|
}
|
2023-05-05 10:08:38 +00:00
|
|
|
}
|