feat: Reinitialize frontend with SvelteKit and TypeScript
- Delete old Vite+Svelte frontend - Initialize new SvelteKit project with TypeScript - Configure Tailwind CSS v4 + DaisyUI - Implement JWT authentication with auto-refresh - Create login page with form validation (Zod) - Add protected route guards - Update Docker configuration for single-stage build - Add E2E tests with Playwright (6/11 passing) - Fix Svelte 5 reactivity with $state() runes Known issues: - 5 E2E tests failing (timing/async issues) - Token refresh implementation needs debugging - Validation error display timing
This commit is contained in:
1
backend/database/.gitignore
vendored
Normal file
1
backend/database/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
28
backend/database/factories/ActualFactory.php
Normal file
28
backend/database/factories/ActualFactory.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Actual;
|
||||
use App\Models\Project;
|
||||
use App\Models\TeamMember;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory\u003c\App\Models\Actual>
|
||||
*/
|
||||
class ActualFactory extends Factory
|
||||
{
|
||||
protected $model = Actual::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'id' => (string) Str::uuid(),
|
||||
'project_id' => Project::factory(),
|
||||
'team_member_id' => TeamMember::factory(),
|
||||
'month' => fake()->dateTimeBetween('-6 months', 'now')->format('Y-m-01'),
|
||||
'hours_logged' => fake()->randomFloat(2, 0, 160),
|
||||
];
|
||||
}
|
||||
}
|
||||
28
backend/database/factories/AllocationFactory.php
Normal file
28
backend/database/factories/AllocationFactory.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Allocation;
|
||||
use App\Models\Project;
|
||||
use App\Models\TeamMember;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory\u003c\App\Models\Allocation>
|
||||
*/
|
||||
class AllocationFactory extends Factory
|
||||
{
|
||||
protected $model = Allocation::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'id' => (string) Str::uuid(),
|
||||
'project_id' => Project::factory(),
|
||||
'team_member_id' => TeamMember::factory(),
|
||||
'month' => fake()->dateTimeBetween('-6 months', '+6 months')->format('Y-m-01'),
|
||||
'allocated_hours' => fake()->randomFloat(2, 0, 160),
|
||||
];
|
||||
}
|
||||
}
|
||||
42
backend/database/factories/ProjectFactory.php
Normal file
42
backend/database/factories/ProjectFactory.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Project;
|
||||
use App\Models\ProjectStatus;
|
||||
use App\Models\ProjectType;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory\u003c\App\Models\Project>
|
||||
*/
|
||||
class ProjectFactory extends Factory
|
||||
{
|
||||
protected $model = Project::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'id' => (string) Str::uuid(),
|
||||
'code' => strtoupper(fake()->unique()->bothify('PRJ-####')),
|
||||
'title' => fake()->sentence(3),
|
||||
'status_id' => ProjectStatus::factory(),
|
||||
'type_id' => ProjectType::factory(),
|
||||
'approved_estimate' => null,
|
||||
'forecasted_effort' => null,
|
||||
];
|
||||
}
|
||||
|
||||
public function approved(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'approved_estimate' => fake()->randomFloat(2, 5000, 50000),
|
||||
'forecasted_effort' => [
|
||||
'frontend' => fake()->numberBetween(40, 200),
|
||||
'backend' => fake()->numberBetween(60, 300),
|
||||
'qa' => fake()->numberBetween(20, 100),
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
24
backend/database/factories/ProjectStatusFactory.php
Normal file
24
backend/database/factories/ProjectStatusFactory.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use App\Models\ProjectStatus;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory\u003c\App\Models\ProjectStatus>
|
||||
*/
|
||||
class ProjectStatusFactory extends Factory
|
||||
{
|
||||
protected $model = ProjectStatus::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->unique()->words(2, true),
|
||||
'order' => fake()->numberBetween(1, 20),
|
||||
'is_active' => fake()->boolean(),
|
||||
'is_billable' => fake()->boolean(),
|
||||
];
|
||||
}
|
||||
}
|
||||
22
backend/database/factories/ProjectTypeFactory.php
Normal file
22
backend/database/factories/ProjectTypeFactory.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use App\Models\ProjectType;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory\u003c\App\Models\ProjectType>
|
||||
*/
|
||||
class ProjectTypeFactory extends Factory
|
||||
{
|
||||
protected $model = ProjectType::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->unique()->word(),
|
||||
'description' => fake()->sentence(),
|
||||
];
|
||||
}
|
||||
}
|
||||
23
backend/database/factories/RoleFactory.php
Normal file
23
backend/database/factories/RoleFactory.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Role;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory\u003c\App\Models\Role>
|
||||
*/
|
||||
class RoleFactory extends Factory
|
||||
{
|
||||
protected $model = Role::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->unique()->jobTitle(),
|
||||
'description' => fake()->sentence(),
|
||||
];
|
||||
}
|
||||
}
|
||||
34
backend/database/factories/TeamMemberFactory.php
Normal file
34
backend/database/factories/TeamMemberFactory.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\TeamMember;
|
||||
use App\Models\Role;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory\u003c\App\Models\TeamMember>
|
||||
*/
|
||||
class TeamMemberFactory extends Factory
|
||||
{
|
||||
protected $model = TeamMember::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'id' => (string) Str::uuid(),
|
||||
'name' => fake()->name(),
|
||||
'role_id' => Role::factory(),
|
||||
'hourly_rate' => fake()->randomFloat(2, 20, 150),
|
||||
'active' => true,
|
||||
];
|
||||
}
|
||||
|
||||
public function inactive(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'active' => false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
45
backend/database/factories/UserFactory.php
Normal file
45
backend/database/factories/UserFactory.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'role' => fake()->randomElement(['superuser', 'manager', 'developer', 'top_brass']),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?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('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration')->index();
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->integer('expiration')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -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('roles', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->unique();
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('roles');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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_statuses', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->unique();
|
||||
$table->integer('order')->default(0);
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->boolean('is_billable')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('project_statuses');
|
||||
}
|
||||
};
|
||||
@@ -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('project_types', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->unique();
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('project_types');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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('team_members', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->string('name');
|
||||
$table->foreignId('role_id')->constrained('roles');
|
||||
$table->decimal('hourly_rate', 10, 2);
|
||||
$table->boolean('active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('team_members');
|
||||
}
|
||||
};
|
||||
@@ -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->uuid('id')->primary();
|
||||
$table->string('code')->unique();
|
||||
$table->string('title');
|
||||
$table->foreignId('status_id')->constrained('project_statuses');
|
||||
$table->foreignId('type_id')->constrained('project_types');
|
||||
$table->decimal('approved_estimate', 12, 2)->nullable();
|
||||
$table->json('forecasted_effort')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('projects');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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('allocations', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->foreignUuid('project_id')->constrained('projects');
|
||||
$table->foreignUuid('team_member_id')->constrained('team_members');
|
||||
$table->date('month'); // First day of the month
|
||||
$table->decimal('allocated_hours', 8, 2)->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
// Composite indexes for common queries
|
||||
$table->index(['project_id', 'month'], 'idx_allocations_project_month');
|
||||
$table->index(['team_member_id', 'month'], 'idx_allocations_member_month');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('allocations');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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('actuals', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->foreignUuid('project_id')->constrained('projects');
|
||||
$table->foreignUuid('team_member_id')->constrained('team_members');
|
||||
$table->date('month'); // First day of the month
|
||||
$table->decimal('hours_logged', 8, 2)->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
// Composite indexes for common queries
|
||||
$table->index(['project_id', 'month'], 'idx_actuals_project_month');
|
||||
$table->index(['team_member_id', 'month'], 'idx_actuals_member_month');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('actuals');
|
||||
}
|
||||
};
|
||||
@@ -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('holidays', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->date('date')->unique();
|
||||
$table->string('name');
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('holidays');
|
||||
}
|
||||
};
|
||||
@@ -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('ptos', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->foreignUuid('team_member_id')->constrained('team_members');
|
||||
$table->date('start_date');
|
||||
$table->date('end_date');
|
||||
$table->string('reason')->nullable();
|
||||
$table->enum('status', ['pending', 'approved', 'rejected'])->default('pending');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ptos');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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
|
||||
{
|
||||
// Drop the default users table and recreate with UUID
|
||||
Schema::dropIfExists('users');
|
||||
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->enum('role', ['superuser', 'manager', 'developer', 'top_brass'])->default('developer');
|
||||
$table->boolean('active')->default(true);
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
};
|
||||
24
backend/database/seeders/DatabaseSeeder.php
Normal file
24
backend/database/seeders/DatabaseSeeder.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
use WithoutModelEvents;
|
||||
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$this->call([
|
||||
RoleSeeder::class,
|
||||
ProjectStatusSeeder::class,
|
||||
ProjectTypeSeeder::class,
|
||||
UserSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
103
backend/database/seeders/ProjectStatusSeeder.php
Normal file
103
backend/database/seeders/ProjectStatusSeeder.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ProjectStatusSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$statuses = [
|
||||
[
|
||||
'name' => 'Pre-sales',
|
||||
'order' => 1,
|
||||
'is_active' => false,
|
||||
'is_billable' => false,
|
||||
],
|
||||
[
|
||||
'name' => 'SOW Approval',
|
||||
'order' => 2,
|
||||
'is_active' => false,
|
||||
'is_billable' => false,
|
||||
],
|
||||
[
|
||||
'name' => 'Estimation',
|
||||
'order' => 3,
|
||||
'is_active' => false,
|
||||
'is_billable' => false,
|
||||
],
|
||||
[
|
||||
'name' => 'Estimate Approved',
|
||||
'order' => 4,
|
||||
'is_active' => false,
|
||||
'is_billable' => false,
|
||||
],
|
||||
[
|
||||
'name' => 'Resource Allocation',
|
||||
'order' => 5,
|
||||
'is_active' => false,
|
||||
'is_billable' => false,
|
||||
],
|
||||
[
|
||||
'name' => 'Sprint 0',
|
||||
'order' => 6,
|
||||
'is_active' => true,
|
||||
'is_billable' => false,
|
||||
],
|
||||
[
|
||||
'name' => 'In Progress',
|
||||
'order' => 7,
|
||||
'is_active' => true,
|
||||
'is_billable' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'UAT',
|
||||
'order' => 8,
|
||||
'is_active' => true,
|
||||
'is_billable' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'Handover / Sign-off',
|
||||
'order' => 9,
|
||||
'is_active' => true,
|
||||
'is_billable' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'Estimate Rework',
|
||||
'order' => 10,
|
||||
'is_active' => false,
|
||||
'is_billable' => false,
|
||||
],
|
||||
[
|
||||
'name' => 'On Hold',
|
||||
'order' => 11,
|
||||
'is_active' => false,
|
||||
'is_billable' => false,
|
||||
],
|
||||
[
|
||||
'name' => 'Cancelled',
|
||||
'order' => 12,
|
||||
'is_active' => false,
|
||||
'is_billable' => false,
|
||||
],
|
||||
[
|
||||
'name' => 'Closed',
|
||||
'order' => 13,
|
||||
'is_active' => false,
|
||||
'is_billable' => false,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($statuses as $status) {
|
||||
DB::table('project_statuses')->updateOrInsert(
|
||||
['name' => $status['name']],
|
||||
$status
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
backend/database/seeders/ProjectTypeSeeder.php
Normal file
33
backend/database/seeders/ProjectTypeSeeder.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ProjectTypeSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$types = [
|
||||
[
|
||||
'name' => 'Project',
|
||||
'description' => 'Full software development project with defined scope, timeline, and deliverables',
|
||||
],
|
||||
[
|
||||
'name' => 'Support',
|
||||
'description' => 'Ongoing support and maintenance with SLA requirements',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($types as $type) {
|
||||
DB::table('project_types')->updateOrInsert(
|
||||
['name' => $type['name']],
|
||||
$type
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
53
backend/database/seeders/RoleSeeder.php
Normal file
53
backend/database/seeders/RoleSeeder.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class RoleSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$roles = [
|
||||
[
|
||||
'name' => 'Frontend Dev',
|
||||
'description' => 'Frontend Developer - specializes in UI/UX and client-side development',
|
||||
],
|
||||
[
|
||||
'name' => 'Backend Dev',
|
||||
'description' => 'Backend Developer - specializes in server-side logic and APIs',
|
||||
],
|
||||
[
|
||||
'name' => 'QA',
|
||||
'description' => 'Quality Assurance - tests software and ensures quality standards',
|
||||
],
|
||||
[
|
||||
'name' => 'DevOps',
|
||||
'description' => 'DevOps Engineer - manages infrastructure, CI/CD, and deployments',
|
||||
],
|
||||
[
|
||||
'name' => 'UX',
|
||||
'description' => 'UX Designer - designs user experiences and interfaces',
|
||||
],
|
||||
[
|
||||
'name' => 'PM',
|
||||
'description' => 'Project Manager - manages projects, timelines, and client communication',
|
||||
],
|
||||
[
|
||||
'name' => 'Architect',
|
||||
'description' => 'Solution Architect - designs system architecture and technical solutions',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($roles as $role) {
|
||||
DB::table('roles')->updateOrInsert(
|
||||
['name' => $role['name']],
|
||||
$role
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
65
backend/database/seeders/UserSeeder.php
Normal file
65
backend/database/seeders/UserSeeder.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Create superuser for testing
|
||||
DB::table('users')->updateOrInsert(
|
||||
['email' => 'superuser@headroom.test'],
|
||||
[
|
||||
'id' => (string) Str::uuid(),
|
||||
'name' => 'Super User',
|
||||
'email' => 'superuser@headroom.test',
|
||||
'password' => Hash::make('password'),
|
||||
'role' => 'superuser',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]
|
||||
);
|
||||
|
||||
// Create test users for each role
|
||||
$testUsers = [
|
||||
[
|
||||
'name' => 'Manager User',
|
||||
'email' => 'manager@headroom.test',
|
||||
'role' => 'manager',
|
||||
],
|
||||
[
|
||||
'name' => 'Developer User',
|
||||
'email' => 'developer@headroom.test',
|
||||
'role' => 'developer',
|
||||
],
|
||||
[
|
||||
'name' => 'Top Brass User',
|
||||
'email' => 'topbrass@headroom.test',
|
||||
'role' => 'top_brass',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($testUsers as $user) {
|
||||
DB::table('users')->updateOrInsert(
|
||||
['email' => $user['email']],
|
||||
[
|
||||
'id' => (string) Str::uuid(),
|
||||
'name' => $user['name'],
|
||||
'email' => $user['email'],
|
||||
'password' => Hash::make('password'),
|
||||
'role' => $user['role'],
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user