Files
muninn/database/factories/TaskFactory.php
T
m105andClaude Sonnet 5 a4ff6c0ccb 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>
2026-08-06 20:41:57 +03:00

93 lines
2.2 KiB
PHP

<?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,
]);
}
}