<?php
/**
 * @var int $page_number
 */

use Itguild\EloquentTable\EloquentDataProvider;
use Itguild\EloquentTable\ListEloquentTable;
use kernel\app_modules\tag\models\Tag;
use kernel\IGTabel\btn\PrimaryBtn;

$table = new ListEloquentTable(new EloquentDataProvider(\kernel\app_modules\tag\models\TagEntity::class, [
    'currentPage' => $page_number,
    'perPage' => 8,
    'params' => ["class" => "table table-bordered", "border" => "2"],
    'baseUrl' => "/admin/tag_entity",
]));

$table->beforePrint(function () {
    return PrimaryBtn::create("Создать", "/admin/tag_entity/create")->fetch();
});
$table->columns([
    "tag_id" => [
        "value" => function ($data) {
            return Tag::find($data)->label;
        }]
]);

$table->addAction(\kernel\IGTabel\action_column\ViewActionColumn::class);
$table->addAction(\kernel\IGTabel\action_column\DeleteActionColumn::class);
$table->addAction(\kernel\IGTabel\action_column\EditActionColumn::class);

\kernel\widgets\TagTabsWidget::create()->run();
$table->create();
$table->render();