TaskFactory.php
1 <?php 2 3 namespace Database\Factories; 4 5 use App\Models\Dossier; 6 use App\Models\Stage; 7 use App\Models\Task; 8 use App\Models\TaskStatus; 9 use App\Models\User; 10 use Illuminate\Database\Eloquent\Factories\Factory; 11 12 class TaskFactory extends Factory 13 { 14 /** 15 * The name of the factory's corresponding model. 16 * 17 * @var string 18 */ 19 protected $model = Task::class; 20 21 /** 22 * Define the model's default state. 23 * 24 * @return array 25 */ 26 public function definition() 27 { 28 return [ 29 'title' => $this->faker->sentence(), 30 'description' => $this->faker->paragraph(), 31 'source' => $this->faker->randomElement(['internal', 'external']), 32 'start_date' => $this->faker->dateTimeBetween('-1 year', 'now'), 33 'end_date' => $this->faker->dateTimeBetween('now', '+1 year'), 34 'user_id' => $this->faker->randomElement(User::pluck('id')), 35 'task_status_id' => TaskStatus::inRandomOrder()->first(), 36 'stage_id' => Stage::first(), 37 'is_milestone' => $this->faker->boolean(), 38 ]; 39 } 40 }