Crear contenido de proyectos

This commit is contained in:
2020-05-19 16:20:29 -04:00
parent 3133a7d584
commit d2f5714291
2 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1,45 @@
<?php
use Carbon\Carbon;
use joshtronic\LoremIpsum;
$__environment = 'web';
include_once implode(DIRECTORY_SEPARATOR, [
dirname(__DIR__),
'bootstrap',
'app.php'
]);
$filename = implode(DIRECTORY_SEPARATOR, [
$app->getContainer()->get('folders.data'),
'segmentos.json'
]);
$segmentos = json_decode(trim(file_get_contents($filename)));
$f = Carbon::today();
$lipsum = new LoremIpsum;
$proyectos = [];
for ($i = 0; $i < 100; $i ++) {
$proyecto = [];
$proyecto['edificio'] = ucwords($lipsum->words(2));
$proyecto['segmento'] = $segmentos[mt_rand(0, count($segmentos) - 1)]->titulo;
$proyecto['direccion'] = ucwords($lipsum->words(2)) . ' ' . mt_rand(10, 59999);
$proyecto['ciudad'] = 'Santiago, Chile';
$proyecto['imagen'] = 'optimus.jpg';
$proyecto['valor'] = number_format(mt_rand() / mt_getrandmax() * 10000, 2, ',', '.');
$proyecto['bono'] = number_format(mt_rand() / mt_getrandmax() * 100, 2, ',', '.');
$proyecto['rentabilidad'] = mt_rand(10, 70);
$proyecto['estado'] = (['Construcción', 'Entrega Inmediata', 'Usado'])[mt_rand(0, 2)];
$proyecto['cuota'] = mt_rand(1, 30);
$proyecto['entrega'] = str_pad(mt_rand(1, 12), 2, '0', STR_PAD_LEFT) . '/' . mt_rand(19, 25);
$proyecto['publicacion'] = $f->copy()->subDays(mt_rand(0, 100))->locale('es')->isoFormat('D \d\e MMMM, YYYY');
$proyecto['unidades'] = mt_rand(10, 300);
$proyecto['modelos'] = mt_rand(1, 20);
$proyecto['tamaño'] = mt_rand(30, 200) . ' - ' . mt_rand(100, 500) . ' m²';
$proyecto['descripcion'] = $lipsum->paragraphs(2);
$proyectos []= (object) $proyecto;
}
$filename = implode(DIRECTORY_SEPARATOR, [
$app->getContainer()->get('folders.data'),
'proyectos.json'
]);
file_put_contents($filename, json_encode($proyectos, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
echo 'OK';