2023-09-22 09:23:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Livewire\Project\Service;
|
|
|
|
|
|
|
|
use App\Models\ServiceDatabase;
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class Database extends Component
|
|
|
|
{
|
|
|
|
public ServiceDatabase $database;
|
2023-09-26 12:45:52 +00:00
|
|
|
public $fileStorages;
|
|
|
|
protected $listeners = ["refreshFileStorages"];
|
2023-09-22 09:23:49 +00:00
|
|
|
protected $rules = [
|
|
|
|
'database.human_name' => 'nullable',
|
2023-09-22 12:47:25 +00:00
|
|
|
'database.description' => 'nullable',
|
2023-09-26 12:45:52 +00:00
|
|
|
'database.image' => 'required',
|
|
|
|
'database.exclude_from_status' => 'required|boolean',
|
2023-09-22 09:23:49 +00:00
|
|
|
];
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return view('livewire.project.service.database');
|
|
|
|
}
|
2023-09-26 12:45:52 +00:00
|
|
|
public function mount() {
|
|
|
|
$this->refreshFileStorages();
|
|
|
|
}
|
2023-09-25 13:48:43 +00:00
|
|
|
public function instantSave() {
|
|
|
|
$this->submit();
|
|
|
|
}
|
2023-09-26 12:45:52 +00:00
|
|
|
public function refreshFileStorages()
|
|
|
|
{
|
|
|
|
$this->fileStorages = $this->database->fileStorages()->get();
|
|
|
|
}
|
2023-09-22 09:23:49 +00:00
|
|
|
public function submit()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$this->validate();
|
|
|
|
$this->database->save();
|
2023-09-27 10:45:53 +00:00
|
|
|
updateCompose($this->database);
|
2023-09-25 13:48:43 +00:00
|
|
|
$this->emit('success', 'Database saved successfully.');
|
2023-09-22 09:23:49 +00:00
|
|
|
} catch (\Throwable $e) {
|
|
|
|
ray($e);
|
|
|
|
} finally {
|
|
|
|
$this->emit('generateDockerCompose');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|