56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
||
|
||
require_once "../vendor/autoload.php";
|
||
|
||
use Itguild\Tables\ListJsonTable;
|
||
|
||
$json = file_get_contents('simple.json');
|
||
$table = new ListJsonTable($json);
|
||
|
||
$table->columns([
|
||
"created_at" => [
|
||
"format" => "date:Y-m-d",
|
||
'filter' => "date"
|
||
],
|
||
'description' => [
|
||
"format" => "html",
|
||
"style" => ["width" => "300px"],
|
||
"filter" => "text",
|
||
"value" => function ($cell) {
|
||
return "<span style='color: sienna'>$cell</span>";
|
||
}
|
||
],
|
||
'status' => [
|
||
"format" => "integer",
|
||
"value" => function ($cell) {
|
||
return getStatusLabel()[$cell];
|
||
}],
|
||
'email' => function ($cell) {
|
||
return "<span style='color: aqua'>$cell</span>";
|
||
},
|
||
]);
|
||
//$table->setBeforePrintCell(function ($key, $data) {
|
||
// return $key == "email" ? "<span style='color: aqua'>$data</span>" : $data;
|
||
//});
|
||
$table->afterPrint(function ($meta) {
|
||
return "<div>After Print</div>";
|
||
});
|
||
$table->addColumn("Колонка 33", "k33", function ($id) {
|
||
return "my ID: " . $id;
|
||
});
|
||
$table->addColumn("Колонка 34", "k34", function ($id) {
|
||
return "some34";
|
||
});
|
||
$table->create();
|
||
$table->render();
|
||
|
||
|
||
function getStatusLabel(): array
|
||
{
|
||
return [
|
||
0 => "На модерации",
|
||
1 => "Активный",
|
||
2 => "Модератор",
|
||
99 => "Удален",
|
||
];
|
||
} |