🗃️ Add database schema, models & seeders (Story 1.2)
Migrations (translations, projects, skills, skill_project), Eloquent models with belongsToMany relations, scopes, and test seeders (74 translations FR/EN, 10 skills, 3 projects, 12 skill-project links). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('translations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('lang', 5);
|
||||
$table->string('key_name', 255);
|
||||
$table->text('value');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['lang', 'key_name'], 'unique_translation');
|
||||
$table->index('lang', 'idx_lang');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('translations');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('projects', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('slug')->unique();
|
||||
$table->string('title_key');
|
||||
$table->string('description_key');
|
||||
$table->string('short_description_key');
|
||||
$table->string('image')->nullable();
|
||||
$table->string('url')->nullable();
|
||||
$table->string('github_url')->nullable();
|
||||
$table->date('date_completed');
|
||||
$table->boolean('is_featured')->default(false);
|
||||
$table->integer('display_order')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('display_order');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('projects');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('skills', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('slug')->unique();
|
||||
$table->string('name_key');
|
||||
$table->string('description_key');
|
||||
$table->string('icon')->nullable();
|
||||
$table->string('category');
|
||||
$table->integer('max_level')->default(5);
|
||||
$table->integer('display_order')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('category');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('skills');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('skill_project', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('skill_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('project_id')->constrained()->cascadeOnDelete();
|
||||
$table->integer('level_before');
|
||||
$table->integer('level_after');
|
||||
$table->string('level_description_key')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['skill_id', 'project_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('skill_project');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user