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

48 lines
1.0 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
use Livewire\Component;
class Add extends Component
{
public $parameters;
public string $name;
public string $mount_path;
public string|null $host_path = null;
2023-05-05 14:20:10 +02:00
protected $listeners = ['clearAddStorage' => 'clear'];
2023-05-05 12:08:38 +02:00
protected $rules = [
'name' => 'required|string',
'mount_path' => 'required|string',
'host_path' => 'string|nullable',
];
2023-06-16 12:35:40 +02:00
protected $validationAttributes = [
'name' => 'name',
'mount_path' => 'mount',
'host_path' => 'host',
];
2023-05-05 12:08:38 +02:00
public function mount()
{
$this->parameters = get_route_parameters();
2023-05-05 12:08:38 +02:00
}
2023-05-05 12:08:38 +02:00
public function submit()
{
$this->validate();
2023-05-05 14:20:10 +02:00
$this->emitUp('submit', [
'name' => $this->name,
'mount_path' => $this->mount_path,
'host_path' => $this->host_path,
]);
}
2023-05-05 14:20:10 +02:00
public function clear()
{
$this->name = '';
$this->mount_path = '';
$this->host_path = null;
2023-05-05 12:08:38 +02:00
}
}