Seeds
This commit is contained in:
42
app/tests/extension/Seeds/ProyectoTipoUnidad.php
Normal file
42
app/tests/extension/Seeds/ProyectoTipoUnidad.php
Normal 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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user