*/ class ConsultationFactory extends Factory { /** * The name of the factory's corresponding model. * * @var string */ protected $model = Consultation::class; /** * Define the model's default state. * * @return array */ public function definition(): array { // Get a random patient from the users table $patient = User::where('user_role', 'user')->inRandomOrder()->first(); // Get a random doctor from the users table $doctor = User::where('user_role', 'doctor')->inRandomOrder()->first(); return [ 'patient_id' => $patient->id, 'doctor_id' => $doctor->id, 'consultation_date' => $this->faker->dateTimeBetween('-1 year', '+1 year')->format('Y-m-d'), 'consultation_time' => $this->faker->time('H:i:s'), 'location' => $this->faker->city, 'consultation_status' => $this->faker->randomElement(['pending', 'declined', 'approved', 'finished']), ]; } }