51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
namespace Tests\Extension\Seeds;
|
|
|
|
use Tests\Extension\AbstractSeed;
|
|
|
|
class Brokers extends AbstractSeed
|
|
{
|
|
public function run(): void
|
|
{
|
|
$addresses = $this->loadValues('direccion', columns: 'id');
|
|
|
|
|
|
|
|
$count = 10;
|
|
$contactData = [];
|
|
for($i = 0; $i < $count; $i++) {
|
|
$rut = $this->faker->rut(false, false);
|
|
$contactData[]= [
|
|
'rut' => $rut,
|
|
'digit' => $this->faker->digitoVerificador($rut),
|
|
'name' => $this->faker->name,
|
|
'email' => $this->faker->email,
|
|
'phone' => $this->faker->phoneNumber,
|
|
'address_id' => $this->faker->randomElement($addresses)
|
|
];
|
|
}
|
|
$this->table('broker_contacts')->insertValues($contactData)->save();
|
|
|
|
$contacts = $this->loadValues('broker_contacts', columns: 'id');
|
|
|
|
$data = [];
|
|
$brokerData = [];
|
|
for($i = 0; $i < $count; $i ++) {
|
|
$rut = $this->faker->rut(false, false);
|
|
$data[] = [
|
|
'rut' => $rut,
|
|
'digit' => $this->faker->digitoVerificador($rut),
|
|
'name' => $this->faker->word
|
|
];
|
|
$brokerData []= [
|
|
'broker_rut' => $rut,
|
|
'representante_id' => $this->faker->randomElement($contacts),
|
|
'legal_name' => $this->faker->company
|
|
];
|
|
}
|
|
|
|
$this->table('brokers')->insertValues($data)->save();
|
|
$this->table('broker_data')->insertValues($brokerData)->save();
|
|
}
|
|
}
|