Laravel_App/resources/views/user/index.blade.php

67 lines
2.0 KiB
PHP
Raw Normal View History

2025-01-13 15:52:38 +03:00
<?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");
}
]);
2025-01-20 16:57:48 +03:00
//$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>";
});
2025-01-13 15:52:38 +03:00
$table->create();
2025-01-20 13:59:35 +03:00
?>
<x-main>
<x-slot:title>
Custom Title
</x-slot>
@php
$table->render();
@endphp
</x-main>