storages
This commit is contained in:
@@ -28,7 +28,6 @@ class Add extends Component
|
||||
{
|
||||
$this->validate();
|
||||
try {
|
||||
|
||||
$application_id = Application::where('uuid', $this->parameters['application_uuid'])->firstOrFail()->id;
|
||||
EnvironmentVariable::create([
|
||||
'key' => $this->key,
|
||||
|
||||
@@ -8,7 +8,7 @@ use Livewire\Component;
|
||||
class All extends Component
|
||||
{
|
||||
public Application $application;
|
||||
protected $listeners = ['refreshEnvs' => 'refreshEnvs'];
|
||||
protected $listeners = ['refreshEnvs'];
|
||||
public function refreshEnvs()
|
||||
{
|
||||
$this->application->refresh();
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Project\Application;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Livewire\Component;
|
||||
|
||||
class Storages extends Component
|
||||
{
|
||||
public Collection $storages;
|
||||
}
|
||||
52
app/Http/Livewire/Project/Application/Storages/Add.php
Normal file
52
app/Http/Livewire/Project/Application/Storages/Add.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Project\Application\Storages;
|
||||
|
||||
use App\Models\Application;
|
||||
use App\Models\LocalPersistentVolume;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Livewire\Component;
|
||||
|
||||
class Add extends Component
|
||||
{
|
||||
public $parameters;
|
||||
public string $name;
|
||||
public string $mount_path;
|
||||
public string|null $host_path = null;
|
||||
protected $rules = [
|
||||
'name' => 'required|string',
|
||||
'mount_path' => 'required|string',
|
||||
'host_path' => 'string|nullable',
|
||||
];
|
||||
public function mount()
|
||||
{
|
||||
$this->parameters = Route::current()->parameters();
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
$this->validate();
|
||||
try {
|
||||
$application_id = Application::where('uuid', $this->parameters['application_uuid'])->firstOrFail()->id;
|
||||
LocalPersistentVolume::create([
|
||||
'name' => $this->name,
|
||||
'mount_path' => $this->mount_path,
|
||||
'host_path' => $this->host_path,
|
||||
'resource_id' => $application_id,
|
||||
'resource_type' => Application::class,
|
||||
]);
|
||||
$this->emit('refreshStorages');
|
||||
$this->name = '';
|
||||
$this->mount_path = '';
|
||||
$this->host_path = '';
|
||||
} catch (mixed $e) {
|
||||
dd('asdf');
|
||||
if ($e instanceof QueryException) {
|
||||
dd($e->errorInfo);
|
||||
$this->emit('error', $e->errorInfo[2]);
|
||||
} else {
|
||||
$this->emit('error', $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
16
app/Http/Livewire/Project/Application/Storages/All.php
Normal file
16
app/Http/Livewire/Project/Application/Storages/All.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Project\Application\Storages;
|
||||
|
||||
use App\Models\Application;
|
||||
use Livewire\Component;
|
||||
|
||||
class All extends Component
|
||||
{
|
||||
public Application $application;
|
||||
protected $listeners = ['refreshStorages'];
|
||||
public function refreshStorages()
|
||||
{
|
||||
$this->application->refresh();
|
||||
}
|
||||
}
|
||||
25
app/Http/Livewire/Project/Application/Storages/Show.php
Normal file
25
app/Http/Livewire/Project/Application/Storages/Show.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Project\Application\Storages;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class Show extends Component
|
||||
{
|
||||
public $storage;
|
||||
protected $rules = [
|
||||
'storage.name' => 'required|string',
|
||||
'storage.mount_path' => 'required|string',
|
||||
'storage.host_path' => 'string|nullable',
|
||||
];
|
||||
public function submit()
|
||||
{
|
||||
$this->validate();
|
||||
$this->storage->save();
|
||||
}
|
||||
public function delete()
|
||||
{
|
||||
$this->storage->delete();
|
||||
$this->emit('refreshStorages');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user