<?php

/**
 * @var \Illuminate\Database\Eloquent\Collection ${slug}
 */

use Itguild\EloquentTable\ViewEloquentTable;
use Itguild\EloquentTable\ViewJsonTableEloquentModel;
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnListWidget;

$table = new ViewEloquentTable(new ViewJsonTableEloquentModel(${slug}, [
    'params' => ["class" => "table table-bordered", "border" => "2"],
    'baseUrl' => "/admin/{slug}",
]));
$table->beforePrint(function () use (${slug}) {
    $btn = IconBtnListWidget::create(['url' => '/admin/{slug}'])->run();
    $btn .= IconBtnEditWidget::create(['url' => '/admin/{slug}/update/' . ${slug}->id])->run();
    $btn .= IconBtnDeleteWidget::create(['url' => '/admin/{slug}/delete/' . ${slug}->id])->run();
    return $btn;
});

$table->create();
$table->render();