2024-07-12 13:46:44 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace app;
|
|
|
|
class foo
|
|
|
|
{
|
|
|
|
public array $informationArray;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $columns
|
|
|
|
* @param array $data
|
2024-07-16 13:37:34 +03:00
|
|
|
* @param string $title
|
2024-07-12 13:46:44 +03:00
|
|
|
* @return string|null
|
|
|
|
*/
|
|
|
|
public function createJsonArray(array $columns, array $data, string $title): ?string
|
|
|
|
{
|
|
|
|
if ($columns && $data) {
|
|
|
|
$this->informationArray = [
|
|
|
|
"meta" => [
|
|
|
|
"title" => $title,
|
|
|
|
"columns" => $columns,
|
|
|
|
"perPage" => 10,
|
|
|
|
"currentPage" => 1,
|
|
|
|
"params" =>
|
|
|
|
[
|
|
|
|
"class" => "table table-bordered",
|
|
|
|
"border" => "1"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
"data" => $data
|
|
|
|
];
|
|
|
|
return $this->toJson($this->informationArray);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $infArr
|
|
|
|
* @return string|null
|
|
|
|
*/
|
|
|
|
protected function toJson(array $infArr): ?string
|
|
|
|
{
|
|
|
|
if ($infArr)
|
|
|
|
return json_encode($infArr, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|