field name consistency

This commit is contained in:
2025-04-07 16:28:27 +01:00
parent 1e7d023b09
commit 32d30e00aa
7 changed files with 14 additions and 8 deletions

View File

@@ -25,7 +25,7 @@ class UninstallFirewallRule
} }
$firewallRule->update([ $firewallRule->update([
'status' => FirewallRuleStatus::UNINSTALLED, 'status' => FirewallRuleStatus::REMOVED,
]); ]);
} }
} }

View File

@@ -8,7 +8,7 @@ enum FirewallRuleStatus: string
{ {
use Arrayable; use Arrayable;
case UNINSTALLED = 'uninstalled'; case NOT_INSTALLED = 'not-installed';
case INSTALLED = 'installed'; case INSTALLED = 'installed';
case FAILED = 'failed'; case FAILED = 'failed';
case REMOVED = 'removed'; case REMOVED = 'removed';

View File

@@ -59,7 +59,8 @@ class ServerController extends Controller
public function store(Request $request) public function store(Request $request)
{ {
$sudoPassword = Str::random(32); $sudoPassword = Str::random(32);
$providerService = app(GetProviderService::class)->execute($request->provider); $provider = Provider::findOrFail($request->provider);
$providerService = $provider->service();
if (! $providerService) { if (! $providerService) {
return back()->with('error', 'Invalid provider'); return back()->with('error', 'Invalid provider');
@@ -76,8 +77,8 @@ class ServerController extends Controller
$server = $organisation->servers()->create([ $server = $organisation->servers()->create([
'name' => $createdServer->name, 'name' => $createdServer->name,
// 'provider' => ServerProvider::tryFrom($request->provider), // @todo 'provider_id' => $provider->id,
'provider_id' => $createdServer->id, 'external_id' => $createdServer->id,
'ipv4' => $createdServer->ipv4, 'ipv4' => $createdServer->ipv4,
'ipv6' => $createdServer->ipv6, 'ipv6' => $createdServer->ipv6,
'provider_status' => $createdServer->status, 'provider_status' => $createdServer->status,

View File

@@ -40,6 +40,11 @@ class Organisation extends Model
return $this->hasMany(Application::class); return $this->hasMany(Application::class);
} }
public function providers(): HasMany
{
return $this->hasMany(Provider::class);
}
public static function createUniqueSlug(string $name): string public static function createUniqueSlug(string $name): string
{ {
$slug = Str::slug($name); $slug = Str::slug($name);

View File

@@ -17,7 +17,7 @@ return new class extends Migration
$table->foreignIdFor(Network::class, 'external_network_id'); $table->foreignIdFor(Network::class, 'external_network_id');
$table->foreignIdFor(Network::class, 'internal_network_id'); $table->foreignIdFor(Network::class, 'internal_network_id');
$table->foreignIdFor(Provider::class); $table->foreignIdFor(Provider::class);
$table->string('provider_external_id')->nullable(); $table->string('external_id')->nullable();
$table->string('name'); $table->string('name');
$table->string('ipv4'); $table->string('ipv4');
$table->string('ipv6'); $table->string('ipv6');

View File

@@ -12,7 +12,7 @@ return new class extends Migration
{ {
Schema::create('firewall_rules', function (Blueprint $table) { Schema::create('firewall_rules', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('status')->default(FirewallRuleStatus::NOT_APPLIED->value); $table->string('status')->default(FirewallRuleStatus::NOT_INSTALLED->value);
$table->foreignIdfor(Server::class); $table->foreignIdfor(Server::class);
$table->string('type'); $table->string('type');
$table->string('ports'); $table->string('ports');

View File

@@ -14,7 +14,7 @@ return new class extends Migration
$table->id(); $table->id();
$table->foreignIdFor(Organisation::class); $table->foreignIdFor(Organisation::class);
$table->foreignIdFor(Provider::class); $table->foreignIdFor(Provider::class);
$table->string('provider_external_id')->nullable(); $table->string('external_id')->nullable();
$table->string('type'); $table->string('type');
$table->string('name'); $table->string('name');
$table->string('ip_range'); $table->string('ip_range');