Files

54 lines
1.3 KiB
PHP
Raw Permalink Normal View History

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