Files
oficial/app/tests/extension/Seeds/Direcciones.php
Juan Pablo Vial a0c2f53c54 Reservation Test
2025-09-09 16:24:58 -03:00

34 lines
955 B
PHP

<?php
namespace Tests\Extension\Seeds;
use Tests\Extension\AbstractSeed;
class Direcciones extends AbstractSeed
{
public function run(): void
{
$comunas = $this->loadValues('comuna', columns: 'id');
$n = 100;
$data = [];
for ($i = 0; $i < $n; $i++) {
$row = [
'calle' => $this->faker->streetName,
'numero' => $this->faker->randomNumber(5),
'comuna' => $this->faker->randomElement($comunas),
'extra' => $this->faker->optional(0.9, '')->words(2, true),
];
$extraRand = ((int) round(rand() / getrandmax())) === 1;
if ($extraRand) {
$nExtra = (int) round(rand(1, 3));
$row['extra'] = $this->faker->words($nExtra, true);
}
$data[] = $row;
}
$this->table('direccion')
->insertValues($data)
->save();
}
}