This commit is contained in:
Juan Pablo Vial
2025-09-09 16:23:48 -03:00
parent c220e7438b
commit a18465cacf
6 changed files with 262 additions and 0 deletions

View File

@ -0,0 +1,42 @@
<?php
namespace Tests\Extension\Seeds;
use Tests\Extension\AbstractSeed;
class ProyectoTipoUnidad extends AbstractSeed
{
public function getDependencies(): array
{
return [
Proyectos::class,
];
}
public function run(): void
{
$projects = $this->loadValues('proyecto', columns: 'id');
$types = $this->loadValues('tipo_unidad', columns: 'id');
$data = [];
foreach ($projects as $project) {
foreach ($types as $type) {
$count = $this->faker->numberBetween(1, 10);
for ($i = 0; $i < $count; $i++) {
$name = $this->faker->word;
$data []= [
'proyecto' => $project,
'tipo' => $type,
'nombre' => $name,
'abreviacion' => substr($name, 0, 3),
'm2' => $this->faker->randomFloat(2, 10, 100),
'logia' => $this->faker->optional(.3, 0)->randomFloat(2, 1, 5),
'terraza' => $this->faker->optional(.3, 0)->randomFloat(2, 2, 30),
'descripcion' => $this->faker->sentence,
];
}
}
}
$this->table('proyecto_tipo_unidad')->insertValues($data)->save();
}
}