wip
This commit is contained in:
parent
653efb6983
commit
7eeaf37873
@ -10,7 +10,7 @@ class TemporaryCheckStatus extends Component
|
|||||||
public $application_id;
|
public $application_id;
|
||||||
|
|
||||||
public function checkStatus() {
|
public function checkStatus() {
|
||||||
dd(Application::find(1)->environments);
|
dd(Application::find(1)->environment);
|
||||||
}
|
}
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
|
@ -4,9 +4,9 @@ namespace App\Models;
|
|||||||
|
|
||||||
class Application extends BaseModel
|
class Application extends BaseModel
|
||||||
{
|
{
|
||||||
public function environments()
|
public function environment()
|
||||||
{
|
{
|
||||||
return $this->morphToMany(Environment::class, 'environmentable');
|
return $this->belongsTo(Environment::class);
|
||||||
}
|
}
|
||||||
public function destination()
|
public function destination()
|
||||||
{
|
{
|
||||||
|
@ -4,8 +4,12 @@ namespace App\Models;
|
|||||||
|
|
||||||
class Database extends BaseModel
|
class Database extends BaseModel
|
||||||
{
|
{
|
||||||
public function environments()
|
public function environment()
|
||||||
{
|
{
|
||||||
return $this->morphToMany(Environment::class, 'environmentable');
|
return $this->morphTo();
|
||||||
|
}
|
||||||
|
public function destination()
|
||||||
|
{
|
||||||
|
return $this->morphTo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,17 +4,13 @@ namespace App\Models;
|
|||||||
|
|
||||||
class Environment extends BaseModel
|
class Environment extends BaseModel
|
||||||
{
|
{
|
||||||
public function environmentables()
|
|
||||||
{
|
|
||||||
return $this->hasMany(EnvironmentAble::class);
|
|
||||||
}
|
|
||||||
public function applications()
|
public function applications()
|
||||||
{
|
{
|
||||||
return $this->morphedByMany(Application::class, 'environmentable');
|
return $this->hasMany(Application::class);
|
||||||
}
|
}
|
||||||
public function databases()
|
public function databases()
|
||||||
{
|
{
|
||||||
return $this->morphedByMany(Database::class, 'environmentable');
|
return $this->hasMany(Database::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,9 +15,6 @@ return new class extends Migration
|
|||||||
$table->id();
|
$table->id();
|
||||||
$table->string('uuid')->unique();
|
$table->string('uuid')->unique();
|
||||||
$table->string('name')->unique();
|
$table->string('name')->unique();
|
||||||
|
|
||||||
$table->nullableMorphs('environments_morph');
|
|
||||||
|
|
||||||
$table->foreignId('project_id');
|
$table->foreignId('project_id');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
<?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('environmentables', function (Blueprint $table) {
|
|
||||||
$table->id();
|
|
||||||
$table->unsignedBigInteger('environment_id');
|
|
||||||
$table->unsignedBigInteger('environmentable_id');
|
|
||||||
$table->string('environmentable_type');
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('environmentables');
|
|
||||||
}
|
|
||||||
};
|
|
@ -15,7 +15,10 @@ return new class extends Migration
|
|||||||
$table->id();
|
$table->id();
|
||||||
$table->string('uuid')->unique();
|
$table->string('uuid')->unique();
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->nullableMorphs('destination');
|
|
||||||
|
$table->morphs('destination');
|
||||||
|
$table->foreignId('environment_id');
|
||||||
|
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,10 @@ return new class extends Migration
|
|||||||
$table->id();
|
$table->id();
|
||||||
$table->string('uuid')->unique();
|
$table->string('uuid')->unique();
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
|
|
||||||
|
$table->morphs('destination');
|
||||||
|
$table->foreignId('environment_id');
|
||||||
|
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,10 @@
|
|||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use App\Models\Destination;
|
|
||||||
use App\Models\Environment;
|
use App\Models\Environment;
|
||||||
use App\Models\Project;
|
|
||||||
use App\Models\StandaloneDocker;
|
use App\Models\StandaloneDocker;
|
||||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
use App\Models\SwarmDocker;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class ApplicationSeeder extends Seeder
|
class ApplicationSeeder extends Seeder
|
||||||
{
|
{
|
||||||
@ -20,13 +17,21 @@ class ApplicationSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
$environment_1 = Environment::find(1);
|
$environment_1 = Environment::find(1);
|
||||||
$standalone_docker_1 = StandaloneDocker::find(1);
|
$standalone_docker_1 = StandaloneDocker::find(1);
|
||||||
|
$swarm_docker_1 = SwarmDocker::find(1);
|
||||||
|
|
||||||
$application_1 = Application::create([
|
Application::create([
|
||||||
'id' => 1,
|
'id' => 1,
|
||||||
'name' => 'My first application',
|
'name' => 'My first application',
|
||||||
|
'environment_id' => $environment_1->id,
|
||||||
'destination_id' => $standalone_docker_1->id,
|
'destination_id' => $standalone_docker_1->id,
|
||||||
'destination_type' => StandaloneDocker::class,
|
'destination_type' => StandaloneDocker::class,
|
||||||
]);
|
]);
|
||||||
$environment_1->applications()->attach($application_1);
|
Application::create([
|
||||||
|
'id' => 2,
|
||||||
|
'name' => 'My Second application',
|
||||||
|
'environment_id' => $environment_1->id,
|
||||||
|
'destination_id' => $swarm_docker_1->id,
|
||||||
|
'destination_type' => SwarmDocker::class,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace Database\Seeders;
|
|||||||
|
|
||||||
use App\Models\Database;
|
use App\Models\Database;
|
||||||
use App\Models\Environment;
|
use App\Models\Environment;
|
||||||
|
use App\Models\StandaloneDocker;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
class DBSeeder extends Seeder
|
class DBSeeder extends Seeder
|
||||||
@ -11,11 +12,15 @@ class DBSeeder extends Seeder
|
|||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
$environment_1 = Environment::find(1);
|
$environment_1 = Environment::find(1);
|
||||||
$database_1 = Database::create([
|
$standalone_docker_1 = StandaloneDocker::find(1);
|
||||||
|
Database::create([
|
||||||
'id' => 1,
|
'id' => 1,
|
||||||
'name'=> "My first database"
|
'name'=> "My first database",
|
||||||
|
'environment_id' => $environment_1->id,
|
||||||
|
'destination_id' => $standalone_docker_1->id,
|
||||||
|
'destination_type' => StandaloneDocker::class,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$environment_1->databases()->attach($database_1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,16 @@
|
|||||||
<h2>Environments</h2>
|
<h2>Environments</h2>
|
||||||
@forelse ($project->environments as $environment)
|
@forelse ($project->environments as $environment)
|
||||||
<p>Environment Name: {{ $environment->name }}</p>
|
<p>Environment Name: {{ $environment->name }}</p>
|
||||||
|
<h2>Applications</h2>
|
||||||
@forelse ($environment->applications as $application)
|
@forelse ($environment->applications as $application)
|
||||||
<p>Application: {{ $application }}</p>
|
<p>Application: {{ $application->name }}</p>
|
||||||
|
<p>Destination: {{ $application->destination }}</p>
|
||||||
|
<p>Destination Class: {{ $application->destination->getMorphClass() }}</p>
|
||||||
<livewire:temporary-check-status :application_id="$application->id" />
|
<livewire:temporary-check-status :application_id="$application->id" />
|
||||||
@empty
|
@empty
|
||||||
<li>No application found</li>
|
<li>No application found</li>
|
||||||
@endforelse
|
@endforelse
|
||||||
|
<h2>Databases</h2>
|
||||||
@forelse ($environment->databases as $database)
|
@forelse ($environment->databases as $database)
|
||||||
<p>Database: {{ $database }}</p>
|
<p>Database: {{ $database }}</p>
|
||||||
@empty
|
@empty
|
||||||
|
Loading…
x
Reference in New Issue
Block a user