<?php

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

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

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