Files
oficial/app/tests/extension/Seeds/Direcciones.php
2025-06-24 21:55:02 -04:00

34 lines
909 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 = 50;
$data = [];
for ($i = 0; $i < $n; $i++) {
$row = [
'calle' => $this->faker->streetName,
'numero' => $this->faker->randomNumber(5),
'comuna' => $this->faker->randomElement($comunas),
'extra' => '',
];
$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();
}
}