Commit the Projects/Tasks/Ideas/TaskComments feature

This was already implemented, migrated, and running live, but had
never been committed. Bringing it into git: Project/Task/Idea/
TaskComment models, their JSON API (CRUD + status transitions,
task comments, idea<->project linking), Livewire UI pages, and the
nav/route wiring for them. All 42 of its own tests pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
m105
2026-08-06 20:41:57 +03:00
co-authored by Claude Sonnet 5
parent 6ff7f78c9c
commit a4ff6c0ccb
39 changed files with 3411 additions and 0 deletions
+104
View File
@@ -0,0 +1,104 @@
<?php
namespace Database\Factories;
use App\Models\Idea;
use App\Models\Project;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class IdeaFactory extends Factory
{
protected $model = Idea::class;
public function definition(): array
{
return [
'title' => fake()->sentence(4),
'description' => fake()->optional()->paragraph(),
'status' => fake()->randomElement(Idea::STATUSES),
'project_id' => null, // Optional link to project
'priority' => fake()->numberBetween(0, 10),
'category' => fake()->optional()->randomElement(Idea::CATEGORIES),
'tags' => fake()->optional()->words(3, true),
'user_id' => User::factory(),
];
}
public function asNew(): static
{
return $this->state(fn () => [
'status' => 'new',
]);
}
public function considered(): static
{
return $this->state(fn () => [
'status' => 'considered',
]);
}
public function planned(): static
{
return $this->state(fn () => [
'status' => 'planned',
]);
}
public function rejected(): static
{
return $this->state(fn () => [
'status' => 'rejected',
]);
}
public function implemented(): static
{
return $this->state(fn () => [
'status' => 'implemented',
]);
}
public function feature(): static
{
return $this->state(fn () => [
'category' => 'feature',
]);
}
public function improvement(): static
{
return $this->state(fn () => [
'category' => 'improvement',
]);
}
public function bugfix(): static
{
return $this->state(fn () => [
'category' => 'bugfix',
]);
}
public function withProject(Project $project = null): static
{
return $this->state(fn () => [
'project_id' => $project ? $project->id : Project::factory()->create()->id,
]);
}
public function highPriority(): static
{
return $this->state(fn () => [
'priority' => fake()->numberBetween(7, 10),
]);
}
public function withTags(array $tags): static
{
return $this->state(fn () => [
'tags' => implode(',', $tags),
]);
}
}
+63
View File
@@ -0,0 +1,63 @@
<?php
namespace Database\Factories;
use App\Models\Project;
use Illuminate\Database\Eloquent\Factories\Factory;
class ProjectFactory extends Factory
{
protected $model = Project::class;
public function definition(): array
{
return [
'name' => fake()->words(2, true),
'description' => fake()->optional()->paragraph(),
'status' => fake()->randomElement(Project::STATUSES),
'due_at' => fake()->optional()->dateTimeBetween('now', '+1 year'),
];
}
public function active(): static
{
return $this->state(fn () => [
'status' => 'active',
]);
}
public function completed(): static
{
return $this->state(fn () => [
'status' => 'completed',
]);
}
public function archived(): static
{
return $this->state(fn () => [
'status' => 'archived',
]);
}
public function onHold(): static
{
return $this->state(fn () => [
'status' => 'on_hold',
]);
}
public function planned(): static
{
return $this->state(fn () => [
'status' => 'planned',
]);
}
public function withDueDate(): static
{
return $this->state(fn () => [
'due_at' => fake()->dateTimeBetween('now', '+1 year'),
]);
}
}
+53
View File
@@ -0,0 +1,53 @@
<?php
namespace Database\Factories;
use App\Models\Task;
use App\Models\TaskComment;
use Illuminate\Database\Eloquent\Factories\Factory;
class TaskCommentFactory extends Factory
{
protected $model = TaskComment::class;
public function definition(): array
{
return [
'task_id' => Task::factory(),
'body' => fake()->paragraph(),
'author_type' => fake()->randomElement(TaskComment::AUTHOR_TYPES),
'author_name' => fake()->name(),
];
}
public function fromUser(): static
{
return $this->state(fn () => [
'author_type' => 'user',
'author_name' => fake()->name(),
]);
}
public function fromAI(): static
{
return $this->state(fn () => [
'author_type' => 'ai',
'author_name' => fake()->randomElement(['AI Assistant', 'ChatBot', 'Virtual Helper']),
]);
}
public function fromSystem(): static
{
return $this->state(fn () => [
'author_type' => 'system',
'author_name' => fake()->randomElement(['System', 'Automation', 'Scheduler']),
]);
}
public function forTask(Task $task): static
{
return $this->state(fn () => [
'task_id' => $task->id,
]);
}
}
+92
View File
@@ -0,0 +1,92 @@
<?php
namespace Database\Factories;
use App\Models\Project;
use App\Models\Task;
use Illuminate\Database\Eloquent\Factories\Factory;
class TaskFactory extends Factory
{
protected $model = Task::class;
public function definition(): array
{
return [
'title' => fake()->sentence(4),
'description' => fake()->optional()->paragraph(),
'status' => fake()->randomElement(Task::STATUSES),
'project_id' => Project::factory(),
'priority' => fake()->numberBetween(0, 10),
'due_at' => fake()->optional()->dateTimeBetween('now', '+1 year'),
'estimated_hours' => fake()->optional()->numberBetween(1, 40),
'actual_hours' => null,
'started_at' => null,
'completed_at' => null,
];
}
public function todo(): static
{
return $this->state(fn () => [
'status' => 'todo',
]);
}
public function inProgress(): static
{
return $this->state(fn () => [
'status' => 'in_progress',
]);
}
public function done(): static
{
return $this->state(fn () => [
'status' => 'done',
'completed_at' => now(),
]);
}
public function blocked(): static
{
return $this->state(fn () => [
'status' => 'blocked',
]);
}
public function waitingReview(): static
{
return $this->state(fn () => [
'status' => 'waiting_review',
]);
}
public function highPriority(): static
{
return $this->state(fn () => [
'priority' => fake()->numberBetween(7, 10),
]);
}
public function lowPriority(): static
{
return $this->state(fn () => [
'priority' => fake()->numberBetween(0, 3),
]);
}
public function withEstimatedHours(int $hours): static
{
return $this->state(fn () => [
'estimated_hours' => $hours,
]);
}
public function forProject(Project $project): static
{
return $this->state(fn () => [
'project_id' => $project->id,
]);
}
}
@@ -0,0 +1,26 @@
<?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('name');
$table->text('description')->nullable();
$table->string('status')->default('active');
$table->dateTime('due_at')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
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
{
public function up(): void
{
Schema::create('tasks', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('description')->nullable();
$table->string('status')->default('todo');
$table->foreignId('project_id')->constrained()->cascadeOnDelete();
$table->integer('priority')->default(0);
$table->dateTime('due_at')->nullable();
$table->dateTime('started_at')->nullable();
$table->dateTime('completed_at')->nullable();
$table->integer('estimated_hours')->nullable();
$table->integer('actual_hours')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('tasks');
}
};
@@ -0,0 +1,26 @@
<?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('task_comments', function (Blueprint $table) {
$table->id();
$table->foreignId('task_id')->constrained()->cascadeOnDelete();
$table->text('body');
$table->string('author_type')->default('user'); // user, ai, system
$table->string('author_name')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('task_comments');
}
};
@@ -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('ideas', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('description')->nullable();
$table->string('status')->default('new'); // new, considered, planned, rejected, implemented
$table->foreignId('project_id')->nullable()->constrained()->nullOnDelete();
$table->integer('priority')->default(0);
$table->string('category')->nullable(); // feature, improvement, bugfix, research, other
$table->string('tags')->nullable(); // comma-separated tags
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('ideas');
}
};