arrayable enums, only use base ubuntu images, server controller tests, server frontend page fixes
This commit is contained in:
14
app/Enums/Concerns/Arrayable.php
Normal file
14
app/Enums/Concerns/Arrayable.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\Concerns;
|
||||
|
||||
trait Arrayable
|
||||
{
|
||||
public static function toArray(): array
|
||||
{
|
||||
$names = array_column(self::cases(), 'name');
|
||||
$values = array_column(self::cases(), 'value');
|
||||
|
||||
return array_combine($names, $values);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Enums\Concerns\Arrayable;
|
||||
|
||||
enum DeploymentStatus: string
|
||||
{
|
||||
use Arrayable;
|
||||
|
||||
case PENDING = 'pending';
|
||||
case IN_PROGRESS = 'in-progress';
|
||||
case COMPLETED = 'completed';
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Enums\Concerns\Arrayable;
|
||||
|
||||
enum FirewallRuleStatus: string
|
||||
{
|
||||
use Arrayable;
|
||||
|
||||
case NOT_APPLIED = 'not-applied';
|
||||
case APPLIED = 'applied';
|
||||
case FAILED = 'failed';
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Enums\Concerns\Arrayable;
|
||||
|
||||
enum OrganisationRole: string
|
||||
{
|
||||
use Arrayable;
|
||||
|
||||
case ADMIN = 'admin';
|
||||
case MEMBER = 'member';
|
||||
}
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Enums\Concerns\Arrayable;
|
||||
|
||||
enum RepositoryType: string
|
||||
{
|
||||
use Arrayable;
|
||||
|
||||
case GIT = 'git';
|
||||
}
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Enums\Concerns\Arrayable;
|
||||
|
||||
enum ServerProvider: string
|
||||
{
|
||||
use Arrayable;
|
||||
|
||||
case HETZNER = 'hetzner';
|
||||
case DIGITAL_OCEAN = 'digital-ocean';
|
||||
}
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Enums\Concerns\Arrayable;
|
||||
|
||||
enum ServerStatus: string
|
||||
{
|
||||
use Arrayable;
|
||||
|
||||
case WAITING_FOR_PROVIDER = 'waiting-for-provider';
|
||||
case PROVIDER_TIMEOUT = 'provider-timeout';
|
||||
case UNPROVISIONED = 'unprovisioned';
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Enums\Concerns\Arrayable;
|
||||
|
||||
enum ServiceCategory: string
|
||||
{
|
||||
use Arrayable;
|
||||
|
||||
case DATABASE = 'database';
|
||||
case APPLICATION = 'application';
|
||||
case GATEWAY = 'gateway';
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Enums\Concerns\Arrayable;
|
||||
|
||||
enum ServiceStatus: string
|
||||
{
|
||||
use Arrayable;
|
||||
|
||||
case NOT_INSTALLED = 'not-installed';
|
||||
case INSTALLING = 'installing';
|
||||
case RUNNING = 'running';
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Enums\Concerns\Arrayable;
|
||||
|
||||
enum ServiceType: string {
|
||||
use Arrayable;
|
||||
|
||||
case FRANKENPHP = 'frankenphp';
|
||||
case PHP_FPM = 'php-fpm';
|
||||
case POSTGRES = 'postgres';
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
@@ -10,6 +11,9 @@ use Illuminate\Support\Str;
|
||||
|
||||
class Organisation extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function owner(): BelongsTo
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use App\Enums\ServerProvider;
|
||||
use App\Enums\ServerStatus;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
@@ -11,6 +12,9 @@ use Spatie\Ssh\Ssh;
|
||||
|
||||
class Server extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected function casts(): array
|
||||
|
||||
@@ -104,6 +104,6 @@ class HetznerService extends ServerProviderService
|
||||
osFlavor: $image['os_flavor'],
|
||||
osVersion: $image['os_version'],
|
||||
);
|
||||
})->values();
|
||||
})->where('osVersion', '!=', 'unknown')->values();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user