<?php
/**
 * @var \Illuminate\Database\Eloquent\Collection $options
 * @var int $page_number
 */

use Itguild\EloquentTable\EloquentDataProvider;
use Itguild\EloquentTable\ListEloquentTable;
use kernel\modules\notification\models\Notification;
use kernel\widgets\IconBtn\IconBtnCreateWidget;
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnViewWidget;

$table = new ListEloquentTable(new EloquentDataProvider(Notification::class, [
    'current_page' => $page_number,
    'per_page' => 5,
    'params' => ["class" => "table table-bordered", "border" => "2"],
    'baseUrl' => "/admin/notification",
]));

$table->beforePrint(function () {
    return IconBtnCreateWidget::create(['url' => '/admin/notification/create'])->run();
});

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

$table->addAction(function($row) {
    return IconBtnViewWidget::create(['url' => '/admin/notification/view/' . $row['id']])->run();
});
$table->addAction(function($row) {
    return IconBtnEditWidget::create(['url' => '/admin/Notification/update/' . $row['id']])->run();
});
$table->addAction(function($row) {
    return IconBtnDeleteWidget::create(['url' => '/admin/Notification/delete/' . $row['id']])->run();
});

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