*/ class ProfesionalFactory extends Factory { /** * The name of the factory's corresponding model. * * @var string */ protected $model = Profesional::class; /** * Define the model's default state. * * @return array */ public function definition(): array { return [ 'matricula' => $this->faker->unique()->numerify('#####'), 'correo' => $this->faker->unique()->safeEmail(), 'dni' => (string) $this->faker->unique()->numberBetween(20000000, 45000000), 'persona_id' => Persona::factory(), 'profesion_id' => Profesion::factory(), 'credencialprofesional_id' => CredencialProfesional::factory(), 'baja_id' => 1, ]; } public function configure(): static { return $this->afterCreating(function (Profesional $profesional) { CredencialProfesional::where('id', $profesional->credencialprofesional_id) ->update(['usuario' => $profesional->dni . '-' . $profesional->profesion_id]); }); } }