Добавил базовые датасеты и агрегации для конструктора отчетов
This commit is contained in:
30
app/Services/Analytics/AnalyticsResult.php
Normal file
30
app/Services/Analytics/AnalyticsResult.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Analytics;
|
||||
|
||||
/**
|
||||
* Результат построения отчёта: описания колонок, строки и итоги.
|
||||
*/
|
||||
readonly class AnalyticsResult
|
||||
{
|
||||
/**
|
||||
* @param Column[] $columns
|
||||
* @param array<int,array<string,mixed>> $rows
|
||||
* @param array<string,mixed> $totals
|
||||
*/
|
||||
public function __construct(
|
||||
public array $columns,
|
||||
public array $rows,
|
||||
public array $totals = [],
|
||||
) {}
|
||||
|
||||
/** @return array<string,mixed> */
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'columns' => array_map(fn (Column $c) => $c->toArray(), $this->columns),
|
||||
'rows' => $this->rows,
|
||||
'totals' => $this->totals,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user