<?php
/**
 * @var \Illuminate\Database\Eloquent\Collection $menuItem
 * @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(Tag::class, [
    'currentPage' => $page_number,
    'perPage' => 8,
    'params' => ["class" => "table table-bordered", "border" => "2"],
    'baseUrl' => "/admin/tag",
]));

$table->beforePrint(function () {
    return PrimaryBtn::create("Создать", "/admin/tag/create")->fetch();
    //return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch();
});

$table->columns([
    "status" => [
        "value" => function ($cell) {
            return Tag::getStatus()[$cell];
        }]
]);

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