Add Service
This commit is contained in:
parent
f7dd65d1e1
commit
f4daffaa89
@ -12,5 +12,9 @@ class Environment extends BaseModel
|
|||||||
{
|
{
|
||||||
return $this->hasMany(Database::class);
|
return $this->hasMany(Database::class);
|
||||||
}
|
}
|
||||||
|
public function services()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Service::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
app/Models/Service.php
Normal file
16
app/Models/Service.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
|
||||||
|
class Service extends BaseModel
|
||||||
|
{
|
||||||
|
public function environment()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Environment::class);
|
||||||
|
}
|
||||||
|
public function destination()
|
||||||
|
{
|
||||||
|
return $this->morphTo();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('services', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('uuid')->unique();
|
||||||
|
$table->string('name');
|
||||||
|
|
||||||
|
$table->morphs('destination');
|
||||||
|
$table->foreignId('environment_id');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('services');
|
||||||
|
}
|
||||||
|
};
|
@ -28,7 +28,7 @@ class ApplicationSeeder extends Seeder
|
|||||||
]);
|
]);
|
||||||
Application::create([
|
Application::create([
|
||||||
'id' => 2,
|
'id' => 2,
|
||||||
'name' => 'My Second application',
|
'name' => 'My second application (Swarm)',
|
||||||
'environment_id' => $environment_1->id,
|
'environment_id' => $environment_1->id,
|
||||||
'destination_id' => $swarm_docker_1->id,
|
'destination_id' => $swarm_docker_1->id,
|
||||||
'destination_type' => SwarmDocker::class,
|
'destination_type' => SwarmDocker::class,
|
||||||
|
@ -20,7 +20,5 @@ class DBSeeder extends Seeder
|
|||||||
'destination_id' => $standalone_docker_1->id,
|
'destination_id' => $standalone_docker_1->id,
|
||||||
'destination_type' => StandaloneDocker::class,
|
'destination_type' => StandaloneDocker::class,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ class DatabaseSeeder extends Seeder
|
|||||||
KubernetesSeeder::class,
|
KubernetesSeeder::class,
|
||||||
ApplicationSeeder::class,
|
ApplicationSeeder::class,
|
||||||
DBSeeder::class,
|
DBSeeder::class,
|
||||||
|
ServiceSeeder::class,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
27
database/seeders/ServiceSeeder.php
Normal file
27
database/seeders/ServiceSeeder.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Environment;
|
||||||
|
use App\Models\Service;
|
||||||
|
use App\Models\StandaloneDocker;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class ServiceSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$environment_1 = Environment::find(1);
|
||||||
|
$standalone_docker_1 = StandaloneDocker::find(1);
|
||||||
|
Service::create([
|
||||||
|
'id' => 1,
|
||||||
|
'name'=> "My first database",
|
||||||
|
'environment_id' => $environment_1->id,
|
||||||
|
'destination_id' => $standalone_docker_1->id,
|
||||||
|
'destination_type' => StandaloneDocker::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -9,7 +9,7 @@
|
|||||||
<p>Project Settings:{{ $project->settings }}</p>
|
<p>Project Settings:{{ $project->settings }}</p>
|
||||||
<h2>Environments</h2>
|
<h2>Environments</h2>
|
||||||
@forelse ($project->environments as $environment)
|
@forelse ($project->environments as $environment)
|
||||||
<p>Environment Name: {{ $environment->name }}</p>
|
<h1>Environment: {{ $environment->name }}</h1>
|
||||||
<h2>Applications</h2>
|
<h2>Applications</h2>
|
||||||
@forelse ($environment->applications as $application)
|
@forelse ($environment->applications as $application)
|
||||||
<h3>{{ $application->name }}</h3>
|
<h3>{{ $application->name }}</h3>
|
||||||
@ -22,9 +22,18 @@
|
|||||||
@forelse ($environment->databases as $database)
|
@forelse ($environment->databases as $database)
|
||||||
<h3>{{ $database->name }}</h3>
|
<h3>{{ $database->name }}</h3>
|
||||||
<p>Database: {{ $database }}</p>
|
<p>Database: {{ $database }}</p>
|
||||||
|
<p>Destination Class: {{ $database->destination->getMorphClass() }}</p>
|
||||||
@empty
|
@empty
|
||||||
<li>No database found</li>
|
<li>No database found</li>
|
||||||
@endforelse
|
@endforelse
|
||||||
|
<h2>Services</h2>
|
||||||
|
@forelse ($environment->services as $service)
|
||||||
|
<h3>{{ $service->name }}</h3>
|
||||||
|
<p>Service: {{ $service }}</p>
|
||||||
|
<p>Destination Class: {{ $service->destination->getMorphClass() }}</p>
|
||||||
|
@empty
|
||||||
|
<li>No service found</li>
|
||||||
|
@endforelse
|
||||||
@empty
|
@empty
|
||||||
<p>No environments found</p>
|
<p>No environments found</p>
|
||||||
@endforelse
|
@endforelse
|
||||||
|
Loading…
x
Reference in New Issue
Block a user