Add projects, environments, applications, databases
This commit is contained in:
parent
ca0a3974e4
commit
1c87146a50
12
app/Http/Controllers/HomeController.php
Normal file
12
app/Http/Controllers/HomeController.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
class HomeController extends Controller
|
||||||
|
{
|
||||||
|
public function show()
|
||||||
|
{
|
||||||
|
$projects = session('currentTeam')->projects;
|
||||||
|
return view('home', ['projects' => $projects]);
|
||||||
|
}
|
||||||
|
}
|
11
app/Models/Application.php
Normal file
11
app/Models/Application.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
class Application extends BaseModel
|
||||||
|
{
|
||||||
|
public function environments()
|
||||||
|
{
|
||||||
|
return $this->morphToMany(Environment::class, 'environmentable');
|
||||||
|
}
|
||||||
|
}
|
11
app/Models/Database.php
Normal file
11
app/Models/Database.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
class Database extends BaseModel
|
||||||
|
{
|
||||||
|
public function environments()
|
||||||
|
{
|
||||||
|
return $this->morphToMany(Environment::class, 'environmentable');
|
||||||
|
}
|
||||||
|
}
|
20
app/Models/Environment.php
Normal file
20
app/Models/Environment.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
class Environment extends BaseModel
|
||||||
|
{
|
||||||
|
public function environmentables()
|
||||||
|
{
|
||||||
|
return $this->hasMany(EnvironmentAble::class);
|
||||||
|
}
|
||||||
|
public function applications()
|
||||||
|
{
|
||||||
|
return $this->morphedByMany(Application::class, 'environmentable');
|
||||||
|
}
|
||||||
|
public function databases()
|
||||||
|
{
|
||||||
|
return $this->morphedByMany(Database::class, 'environmentable');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
13
app/Models/Project.php
Normal file
13
app/Models/Project.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
class Project extends BaseModel
|
||||||
|
{
|
||||||
|
public function environments() {
|
||||||
|
return $this->hasMany(Environment::class);
|
||||||
|
}
|
||||||
|
public function settings() {
|
||||||
|
return $this->hasOne(ProjectSetting::class);
|
||||||
|
}
|
||||||
|
}
|
7
app/Models/ProjectSetting.php
Normal file
7
app/Models/ProjectSetting.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
class ProjectSetting extends BaseModel
|
||||||
|
{
|
||||||
|
}
|
@ -10,4 +10,7 @@ class Team extends BaseModel
|
|||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
];
|
];
|
||||||
|
public function projects() {
|
||||||
|
return $this->hasMany(Project::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
<?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('projects', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('uuid')->unique();
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('description')->nullable();
|
||||||
|
|
||||||
|
$table->foreignId('team_id');
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('projects');
|
||||||
|
}
|
||||||
|
};
|
@ -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('project_settings', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('uuid')->unique();
|
||||||
|
$table->string('wildcard_domain')->nullable();
|
||||||
|
|
||||||
|
$table->foreignId('project_id');
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('project_settings');
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,33 @@
|
|||||||
|
<?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('environments', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('uuid')->unique();
|
||||||
|
$table->string('name')->unique();
|
||||||
|
|
||||||
|
$table->nullableMorphs('environments_morph');
|
||||||
|
|
||||||
|
$table->foreignId('project_id');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('environments');
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,30 @@
|
|||||||
|
<?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');
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,29 @@
|
|||||||
|
<?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('applications', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('uuid')->unique();
|
||||||
|
$table->string('name');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('applications');
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,29 @@
|
|||||||
|
<?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('databases', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('uuid')->unique();
|
||||||
|
$table->string('name');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('databases');
|
||||||
|
}
|
||||||
|
};
|
25
database/seeders/ApplicationSeeder.php
Normal file
25
database/seeders/ApplicationSeeder.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Application;
|
||||||
|
use App\Models\Environment;
|
||||||
|
use App\Models\Project;
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class ApplicationSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$environment_1 = Environment::find(1);
|
||||||
|
$application_1 = Application::create([
|
||||||
|
'id' => 1,
|
||||||
|
'name' => 'My first application',
|
||||||
|
]);
|
||||||
|
$environment_1->applications()->attach($application_1);
|
||||||
|
}
|
||||||
|
}
|
21
database/seeders/DBSeeder.php
Normal file
21
database/seeders/DBSeeder.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Database;
|
||||||
|
use App\Models\Environment;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class DBSeeder extends Seeder
|
||||||
|
{
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$environment_1 = Environment::find(1);
|
||||||
|
$database_1 = Database::create([
|
||||||
|
'id' => 1,
|
||||||
|
'name'=> "My first database"
|
||||||
|
]);
|
||||||
|
|
||||||
|
$environment_1->databases()->attach($database_1);
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,11 @@ public function run(): void
|
|||||||
TeamSeeder::class,
|
TeamSeeder::class,
|
||||||
ServerSeeder::class,
|
ServerSeeder::class,
|
||||||
PrivateKeySeeder::class,
|
PrivateKeySeeder::class,
|
||||||
|
ProjectSeeder::class,
|
||||||
|
ProjectSettingSeeder::class,
|
||||||
|
EnvironmentSeeder::class,
|
||||||
|
ApplicationSeeder::class,
|
||||||
|
DBSeeder::class,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
24
database/seeders/EnvironmentSeeder.php
Normal file
24
database/seeders/EnvironmentSeeder.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Environment;
|
||||||
|
use App\Models\Project;
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class EnvironmentSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$project_1 = Project::find(1);
|
||||||
|
Environment::create([
|
||||||
|
'id' => 1,
|
||||||
|
'name' => 'production',
|
||||||
|
'project_id' => $project_1->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
21
database/seeders/ProjectSeeder.php
Normal file
21
database/seeders/ProjectSeeder.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\Team;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class ProjectSeeder extends Seeder
|
||||||
|
{
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$root_team = Team::find(1);
|
||||||
|
Project::create([
|
||||||
|
'id' => 1,
|
||||||
|
'name' => "My first project",
|
||||||
|
'description' => "This is a test project in development",
|
||||||
|
'team_id' => $root_team->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
20
database/seeders/ProjectSettingSeeder.php
Normal file
20
database/seeders/ProjectSettingSeeder.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\ProjectSetting;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class ProjectSettingSeeder extends Seeder
|
||||||
|
{
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$first_project = Project::find(1);
|
||||||
|
ProjectSetting::create([
|
||||||
|
'id' => 1,
|
||||||
|
'wildcard_domain' => 'testing-host.localhost',
|
||||||
|
'project_id' => $first_project->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
<nav>
|
<nav>
|
||||||
<a href="/">Home</a>
|
|
||||||
@guest
|
@guest
|
||||||
<a href="/login">Login</a>
|
<a href="/login">Login</a>
|
||||||
<a href="/register">Register</a>
|
<a href="/register">Register</a>
|
||||||
@endguest
|
@endguest
|
||||||
@auth
|
@auth
|
||||||
|
<a href="/">Home</a>
|
||||||
<a href="/demo">Demo</a>
|
<a href="/demo">Demo</a>
|
||||||
<a href="/profile">Profile</a>
|
<a href="/profile">Profile</a>
|
||||||
<form action="/logout" method="POST">
|
<form action="/logout" method="POST">
|
||||||
|
@ -2,9 +2,23 @@
|
|||||||
<h1>
|
<h1>
|
||||||
Coolify v4 🎉
|
Coolify v4 🎉
|
||||||
</h1>
|
</h1>
|
||||||
@guest
|
<h2>Projects</h2>
|
||||||
<p>
|
<ul>
|
||||||
To see the demo, please <a href='/login'>login<a> or <a href='/register'>register<a>.
|
@forelse ($projects as $project)
|
||||||
</p>
|
<li>
|
||||||
@endguest
|
<p>Project Name: {{ $project->name }}</p>
|
||||||
|
<p>Project Settings:{{ $project->settings }}</p>
|
||||||
|
<h2>Environments</h2>
|
||||||
|
@forelse ($project->environments as $environment)
|
||||||
|
<p>Environment Name: {{ $environment->name }}</p>
|
||||||
|
<p>Applications: {{ $environment->applications }}</p>
|
||||||
|
<p>Databases: {{ $environment->databases }}</p>
|
||||||
|
@empty
|
||||||
|
<p>No environments found</p>
|
||||||
|
@endforelse
|
||||||
|
</li>
|
||||||
|
@empty
|
||||||
|
<li>No projects found</li>
|
||||||
|
@endforelse
|
||||||
|
</ul>
|
||||||
</x-layout>
|
</x-layout>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Http\Controllers\HomeController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -13,11 +14,10 @@
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Route::get('/', function () {
|
|
||||||
return view('home');
|
|
||||||
});
|
|
||||||
|
|
||||||
Route::middleware(['auth'])->group(function () {
|
Route::middleware(['auth'])->group(function () {
|
||||||
|
Route::get('/', [HomeController::class, 'show']);
|
||||||
Route::get('/profile', function () {
|
Route::get('/profile', function () {
|
||||||
return view('profile');
|
return view('profile');
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user