tables/examples/simple.php

44 lines
1.1 KiB
PHP
Raw Normal View History

2024-05-27 12:59:44 +03:00
<?php
2024-07-30 12:20:16 +03:00
require_once "../vendor/autoload.php";
2024-05-27 12:59:44 +03:00
use Itguild\Tables\ListJsonTable;
$json = file_get_contents('simple.json');
$table = new ListJsonTable($json);
2024-08-01 13:32:31 +03:00
//$table->column("status", function ($ceil){
// return getStatusLabel()[$ceil];
//});
//$table->columns([
// 'status' => function ($ceil) {
// return getStatusLabel()[$ceil];
// },
// 'email' => function ($ceil) {
// return "<span style='color: aqua'>$ceil</span>";
// }
//]);
//$table->setBeforePrintCell(function ($key, $data) {
// return $key == "email" ? "<span style='color: aqua'>$data</span>" : $data;
//});
2024-07-31 12:48:26 +03:00
$table->afterPrint(function ($meta) {
2024-07-30 12:20:16 +03:00
return "<div>After Print</div>";
});
2024-08-01 13:32:31 +03:00
$table->addColumn("Колонка 33", "k33", function ($id) {
2024-07-31 17:11:29 +03:00
return "my ID: " . $id;
});
2024-08-01 13:32:31 +03:00
$table->addColumn("Колонка 34", "k34", function ($id) {
2024-07-31 17:11:29 +03:00
return "some34";
});
2024-05-27 12:59:44 +03:00
$table->create();
2024-08-01 13:32:31 +03:00
$table->render();
function getStatusLabel(): array
{
return [
0 => "На модерации",
1 => "Активный",
2 => "Модератор",
99 => "Удален",
];
}