93 lines
2.2 KiB
PHP
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,
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
}
|