engelsystem/src/Controllers/DesignController.php

92 lines
3.0 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace Engelsystem\Controllers;
use Carbon\CarbonImmutable;
2021-04-10 17:02:34 +02:00
use Engelsystem\Config\Config;
use Engelsystem\Helpers\BarChart;
use Engelsystem\Http\Response;
use Engelsystem\Models\User\PersonalData;
use Engelsystem\Models\User\State;
use Engelsystem\Models\User\User;
class DesignController extends BaseController
{
public function __construct(protected Response $response, protected Config $config)
{
}
/**
* Show the design overview page
*/
public function index(): Response
{
$demoUser = (new User())->forceFill([
2021-04-10 17:02:34 +02:00
'id' => 42,
'name' => 'test',
]);
$demoUser->__set('state', (new State())->forceFill([
'user_id' => 42,
'arrived' => true,
]));
$demoUser2 = (new User())->forceFill([
2021-04-10 17:02:34 +02:00
'id' => 1337,
'name' => 'test2',
]);
$demoUser2->__set('state', (new State())->forceFill([
'user_id' => 1337,
'arrived' => false,
]));
$demoUser2->__set('personalData', (new PersonalData())->forceFill([
'pronoun' => 'it/its',
]));
$selectOptions = [];
for ($i = 1; $i <= 50; $i++) {
$selectOptions['option_' . $i] = 'Option ' . $i;
}
$dateSelectOptions = [];
$date = CarbonImmutable::now();
for ($i = 1; $i <= 600; $i++) {
$formattedDate = $date->format("Y-m-d");
$dateSelectOptions[$formattedDate] = $formattedDate;
$date = $date->addDay();
}
$themes = $this->config->get('themes');
$date = new \DateTimeImmutable();
2021-04-10 17:02:34 +02:00
$data = [
'demo_user' => $demoUser,
'demo_user_2' => $demoUser2,
'themes' => $themes,
'bar_chart' => BarChart::render(...BarChart::generateChartDemoData(23)),
2022-10-18 21:16:05 +02:00
'timestamp30m' => $date->add(new \DateInterval('PT30M')),
'timestamp59m' => $date->add(new \DateInterval('PT59M')),
'timestamp1h' => $date->add(new \DateInterval('PT1H')),
'timestamp1h30m' => $date->add(new \DateInterval('PT1H30M')),
'timestamp1h31m' => $date->add(new \DateInterval('PT1H31M')),
'timestamp2h' => $date->add(new \DateInterval('PT2H')),
'timestamp2d' => $date->add(new \DateInterval('P2D')),
'timestamp3m' => $date->add(new \DateInterval('P3M')),
'timestamp22y' => $date->add(new \DateInterval('P22Y')),
'timestamp30s' => $date->add(new \DateInterval('PT30S')),
'timestamp30mago' => $date->sub(new \DateInterval('PT30M')),
'timestamp45mago' => $date->sub(new \DateInterval('PT45M')),
'selectOptions' => $selectOptions,
'dateSelectOptions' => $dateSelectOptions,
2021-04-10 17:02:34 +02:00
];
return $this->response->withView(
'pages/design',
2021-04-10 17:02:34 +02:00
$data
);
}
}