<?php

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

use kernel\modules\user\models\User;
use Itguild\EloquentTable\ViewEloquentTable;
use Itguild\EloquentTable\ViewJsonTableEloquentModel;
use kernel\IGTabel\btn\DangerBtn;
use kernel\IGTabel\btn\PrimaryBtn;
use kernel\IGTabel\btn\SuccessBtn;
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnListWidget;

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

$table->rows([
    'image' => function ($data) {
        return $data ? "<img src='$data' width='300px'>" : "";
    }
]);
$table->create();
$table->render();