67 lines
2.0 KiB
PHP
67 lines
2.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @var int $page_number
|
|
*/
|
|
|
|
use App\Models\User;
|
|
use Itguild\EloquentTable\EloquentDataProvider;
|
|
use Itguild\EloquentTable\ListEloquentTable;
|
|
|
|
$table = new ListEloquentTable(new EloquentDataProvider(User::class, [
|
|
'currentPage' => $page_number,
|
|
'perPage' => 3,
|
|
'params' => ["class" => "table table-bordered", "border" => "2"],
|
|
'baseUrl' => "/admin/user",
|
|
'searchPrefix' => "",
|
|
]));
|
|
|
|
$table->columns([
|
|
'user_photo' => function ($data) {
|
|
return $data ? "<img src='$data' width='150px'>" : "";
|
|
},
|
|
'created_at' => function ($data) {
|
|
if (!$data) {
|
|
return null;
|
|
}
|
|
|
|
return (new DateTimeImmutable($data))->format("d-m-Y");
|
|
},
|
|
'updated_at' => function ($data) {
|
|
if (!$data) {
|
|
return null;
|
|
}
|
|
|
|
return (new DateTimeImmutable($data))->format("d-m-Y");
|
|
}
|
|
]);
|
|
//$table->beforePrint(function () {
|
|
// return IconBtnCreateWidget::create(['url' => '/admin/user/create'])->run();
|
|
//});
|
|
$table->beforePrint(function () {
|
|
return "<a title='Создать' class='btn btn-success' href='/admin/user/create' style='margin: 3px' ><i class='fa-regular fa-square-plus'></i></a>";
|
|
});
|
|
$table->addAction(function($row) {
|
|
return "<a title='Просмотреть' class='btn btn-primary' href='/admin/user/view/" . $row['id'] . "' style='margin: 3px' ><i class='<i class='fa-regular fa-eye'></i></a>";
|
|
});
|
|
$table->addAction(function($row) {
|
|
return "<a title='Редактировать' class='btn btn-success' href='/admin/user/update/" . $row['id'] . "' style='margin: 3px' ><i class='fa-solid fa-pen'></i></a>";
|
|
});
|
|
$table->addAction(function($row) {
|
|
return "<a title='Удалить' class='btn btn-danger' href='/admin/user/delete/" . $row['id'] . "' style='margin: 3px' ><i class='fa-regular fa-trash-can'></i></a>";
|
|
});
|
|
$table->create();
|
|
|
|
?>
|
|
<x-main>
|
|
<x-slot:title>
|
|
Custom Title
|
|
</x-slot>
|
|
|
|
@php
|
|
$table->render();
|
|
@endphp
|
|
|
|
</x-main>
|
|
|