2023-05-05 10:08:38 +00:00
|
|
|
<?php
|
|
|
|
|
2023-08-07 20:14:21 +00:00
|
|
|
namespace App\Http\Livewire\Project\Shared\Storages;
|
2023-05-05 10:08:38 +00:00
|
|
|
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class Add extends Component
|
|
|
|
{
|
2023-10-02 07:08:41 +00:00
|
|
|
public $uuid;
|
2023-05-05 10:08:38 +00:00
|
|
|
public $parameters;
|
|
|
|
public string $name;
|
|
|
|
public string $mount_path;
|
|
|
|
public string|null $host_path = null;
|
2023-05-05 12:20:10 +00:00
|
|
|
|
|
|
|
protected $listeners = ['clearAddStorage' => 'clear'];
|
2023-05-05 10:08:38 +00:00
|
|
|
protected $rules = [
|
|
|
|
'name' => 'required|string',
|
|
|
|
'mount_path' => 'required|string',
|
|
|
|
'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-05-05 10:08:38 +00:00
|
|
|
public function mount()
|
|
|
|
{
|
2023-08-09 13:57:53 +00:00
|
|
|
$this->parameters = get_route_parameters();
|
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 submit()
|
|
|
|
{
|
|
|
|
$this->validate();
|
2023-10-02 07:08:41 +00:00
|
|
|
$name = $this->uuid . '-' . $this->name;
|
2023-10-04 07:58:39 +00:00
|
|
|
$this->emit('addNewVolume', [
|
2023-10-02 07:08:41 +00:00
|
|
|
'name' => $name,
|
2023-05-05 12:20:10 +00:00
|
|
|
'mount_path' => $this->mount_path,
|
|
|
|
'host_path' => $this->host_path,
|
|
|
|
]);
|
|
|
|
}
|
2023-08-08 09:51:36 +00:00
|
|
|
|
2023-05-05 12:20:10 +00:00
|
|
|
public function clear()
|
|
|
|
{
|
|
|
|
$this->name = '';
|
|
|
|
$this->mount_path = '';
|
|
|
|
$this->host_path = null;
|
2023-05-05 10:08:38 +00:00
|
|
|
}
|
|
|
|
}
|