<?php
if(!@$line) $line = \App\Models\StatTreeLine::where('uid', $uid)->first();
$total = 0;
$rows = [];
$columns = [];
$selectColumns = [];
$paginator = null;
foreach ($line->reportColumns as $reportColumn) {
    $columns[] = [
        "label" => $reportColumn->label,
        "column" => $reportColumn->display_key,
        "type" => $reportColumn->field_type,
        "as" => "v_{$reportColumn->id}"
    ];
    $selectColumns[] = "{$reportColumn->display_key} as v_{$reportColumn->id}";
}
if(count($line->reportColumns)) {
    $result = \App\Http\Controllers\StatTreeLineController::queryStatTreeLineData($line, $selectColumns, $columns, request());
    $total = $result[0];
    $rows = $result[1];
    $paginator = new \Illuminate\Pagination\LengthAwarePaginator($rows, $total, request()->input('per_page') ?: 20, request()->input('page') ?: 1);
    $paginator->setPath(request()->route()->toSymfonyRoute()->getPath());
}
?>
@include('app.stat-tree.stat-tree-lines.view-data-inline', compact('line', 'total', 'rows', 'columns', 'paginator'))
