Implement projects and project keys

This commit is contained in:
2026-03-25 00:44:37 +01:00
parent aeee3d2640
commit 7d4b0733b3
16 changed files with 716 additions and 1 deletions
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace Database\Factories;
use App\Models\Project;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<Project>
*/
class ProjectFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => Str::title(fake()->unique()->words(asText: true)),
'key' => Str::upper(fake()->unique()->lexify('?????')),
];
}
}
@@ -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('projects', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('key', 5)->unique();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('projects');
}
};
+1
View File
@@ -13,6 +13,7 @@ class DatabaseSeeder extends Seeder
public function run(): void
{
$this->call([
ProjectSeeder::class,
UserSeeder::class,
]);
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace Database\Seeders;
use App\Models\Project;
use Illuminate\Database\Seeder;
class ProjectSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Project::factory()
->count(3)
->sequence(
['name' => 'Core Platform', 'key' => 'CORE'],
['name' => 'Authentication', 'key' => 'AUTH'],
['name' => 'Operations', 'key' => 'OPS'],
)
->create();
}
}