wip
This commit is contained in:
@@ -19,9 +19,9 @@ class Change extends Component
|
||||
{
|
||||
$this->private_key = PrivateKey::where('uuid', $this->private_key_uuid)->first();
|
||||
}
|
||||
public function delete($private_key_uuid)
|
||||
public function delete()
|
||||
{
|
||||
PrivateKey::where('uuid', $private_key_uuid)->delete();
|
||||
PrivateKey::where('uuid', $this->private_key_uuid)->delete();
|
||||
session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
|
||||
redirect()->route('dashboard');
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Project\Application;
|
||||
|
||||
use App\Models\Application;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Livewire\Component;
|
||||
|
||||
class EnvironmentVariable extends Component
|
||||
{
|
||||
public $parameters;
|
||||
public $env;
|
||||
public string|null $keyName = null;
|
||||
public string|null $value = null;
|
||||
public bool $isBuildOnly = false;
|
||||
public bool $isNewEnv = false;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->parameters = Route::current()->parameters();
|
||||
if (data_get($this->env, 'value') !== null) {
|
||||
$this->value = $this->env['value'];
|
||||
$this->isBuildOnly = $this->env['isBuildOnly'];
|
||||
} else {
|
||||
$this->isNewEnv = true;
|
||||
}
|
||||
}
|
||||
public function updateEnv()
|
||||
{
|
||||
$application = Application::where('uuid', $this->parameters['application_uuid'])->first();
|
||||
$application->environment_variables->set("{$this->keyName}.value", $this->value);
|
||||
$application->environment_variables->set("{$this->keyName}.isBuildOnly", $this->isBuildOnly);
|
||||
$application->save();
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
$this->updateEnv();
|
||||
$this->emit('reloadWindow');
|
||||
}
|
||||
public function delete()
|
||||
{
|
||||
$application = Application::where('uuid', $this->parameters['application_uuid'])->first();
|
||||
$application->environment_variables->forget($this->keyName);
|
||||
$application->save();
|
||||
$this->emit('reloadWindow');
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Project\Application;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class EnvironmentVariables extends Component
|
||||
{
|
||||
public array $envs = [];
|
||||
}
|
||||
@@ -4,6 +4,8 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Spatie\SchemalessAttributes\Casts\SchemalessAttributes;
|
||||
|
||||
class Application extends BaseModel
|
||||
{
|
||||
@@ -20,6 +22,7 @@ class Application extends BaseModel
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'description',
|
||||
@@ -35,6 +38,13 @@ class Application extends BaseModel
|
||||
'ports_exposes',
|
||||
'publish_directory',
|
||||
];
|
||||
public $casts = [
|
||||
'environment_variables' => SchemalessAttributes::class,
|
||||
];
|
||||
public function scopeWithEnvironmentVariables(): Builder
|
||||
{
|
||||
return $this->environment_variables->modelScope();
|
||||
}
|
||||
|
||||
public function publishDirectory(): Attribute
|
||||
{
|
||||
|
||||
@@ -23,21 +23,26 @@ class Server extends BaseModel
|
||||
'team_id',
|
||||
'private_key_id',
|
||||
];
|
||||
|
||||
public $casts = [
|
||||
'extra_attributes' => SchemalessAttributes::class,
|
||||
];
|
||||
|
||||
public function standaloneDockers()
|
||||
{
|
||||
return $this->hasMany(StandaloneDocker::class);
|
||||
}
|
||||
|
||||
public function swarmDockers()
|
||||
{
|
||||
return $this->hasMany(SwarmDocker::class);
|
||||
}
|
||||
public $casts = [
|
||||
'extra_attributes' => SchemalessAttributes::class,
|
||||
];
|
||||
|
||||
public function scopeWithExtraAttributes(): Builder
|
||||
{
|
||||
return $this->extra_attributes->modelScope();
|
||||
}
|
||||
|
||||
public function privateKey()
|
||||
{
|
||||
return $this->belongsTo(PrivateKey::class);
|
||||
|
||||
Reference in New Issue
Block a user