*/ class ClienteFactory extends Factory { /** * The name of the factory's corresponding model. * * @var string */ protected $model = Cliente::class; /** * Define the model's default state. * * @return array */ public function definition(): array { return [ 'dni' => (string) $this->faker->unique()->numberBetween(20000000, 45000000), 'correo' => $this->faker->unique()->safeEmail(), 'persona_id' => Persona::factory(), 'baja_id' => 1, 'credencialcliente_id' => CredencialCliente::factory(), ]; } public function configure(): static { return $this->afterCreating(function (Cliente $cliente) { CredencialCliente::where('id', $cliente->credencialcliente_id) ->update([ 'correo' => $cliente->correo, 'contra' => Hash::make($cliente->dni), ]); }); } }