<?php

/**
 * @var \Illuminate\Database\Eloquent\Collection $view
 */

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($view, [
    'params' => ["class" => "table table-bordered", "border" => "2"],
    'baseUrl' => "/admin/view",
]));
$table->beforePrint(function () use ($view) {
    $btn = IconBtnListWidget::create(['url' => '/admin/view'])->run();
    $btn .= IconBtnEditWidget::create(['url' => '/admin/view/update/' . $view->id])->run();
    $btn .= IconBtnDeleteWidget::create(['url' => '/admin/view/delete/' . $view->id])->run();
    return $btn;
});

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