Estructura de base de datos, migraciones, factories y seeders
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Models\Cliente;
|
||||
use App\Models\CredencialCliente;
|
||||
use App\Models\Persona;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Cliente>
|
||||
@@ -30,8 +31,19 @@ class ClienteFactory extends Factory
|
||||
'dni' => (string) $this->faker->unique()->numberBetween(20000000, 45000000),
|
||||
'correo' => $this->faker->unique()->safeEmail(),
|
||||
'persona_id' => Persona::factory(),
|
||||
'baja_id' => null,
|
||||
'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),
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user