2024-12-12 11:58:55 +03:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var \Illuminate\Database\Eloquent\Collection ${slug}
|
|
|
|
|
* @var int $page_number
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
use kernel\app_modules\{slug}\models\{model};
|
|
|
|
|
use Itguild\EloquentTable\EloquentDataProvider;
|
|
|
|
|
use Itguild\EloquentTable\ListEloquentTable;
|
|
|
|
|
use kernel\widgets\IconBtn\IconBtnCreateWidget;
|
|
|
|
|
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
|
|
|
|
|
use kernel\widgets\IconBtn\IconBtnEditWidget;
|
|
|
|
|
use kernel\widgets\IconBtn\IconBtnViewWidget;
|
|
|
|
|
|
2024-12-12 12:41:45 +03:00
|
|
|
|
//Для использования таблицы с моделью, необходимо создать таблицу в базе данных
|
|
|
|
|
//$table = new ListEloquentTable(new EloquentDataProvider({model}::class, [
|
|
|
|
|
// 'currentPage' => $page_number,
|
|
|
|
|
// 'perPage' => 8,
|
|
|
|
|
// 'params' => ["class" => "table table-bordered", "border" => "2"],
|
|
|
|
|
// 'baseUrl' => "/admin/{slug}"
|
|
|
|
|
//]));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$table = new \Itguild\Tables\ListJsonTable(json_encode(
|
|
|
|
|
[
|
|
|
|
|
'meta' => [
|
|
|
|
|
'total' => 0,
|
|
|
|
|
'totalWithFilters' => 0,
|
|
|
|
|
'columns' => [
|
|
|
|
|
'title',
|
|
|
|
|
'slug',
|
|
|
|
|
'status',
|
|
|
|
|
],
|
|
|
|
|
'perPage' => 5,
|
|
|
|
|
'currentPage' => 1,
|
|
|
|
|
'baseUrl' => '/admin/some',
|
|
|
|
|
'params' => [
|
|
|
|
|
'class' => 'table table-bordered',
|
|
|
|
|
'border' => 2
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'filters' => [],
|
|
|
|
|
'data' => [],
|
|
|
|
|
]
|
|
|
|
|
));
|
2024-12-12 11:58:55 +03:00
|
|
|
|
|
|
|
|
|
$table->beforePrint(function () {
|
|
|
|
|
return IconBtnCreateWidget::create(['url' => '/admin/{slug}/create'])->run();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$table->addAction(function($row) {
|
|
|
|
|
return IconBtnViewWidget::create(['url' => '/admin/{slug}/view/' . $row['id']])->run();
|
|
|
|
|
});
|
|
|
|
|
$table->addAction(function($row) {
|
|
|
|
|
return IconBtnEditWidget::create(['url' => '/admin/{slug}/update/' . $row['id']])->run();
|
|
|
|
|
});
|
|
|
|
|
$table->addAction(function($row) {
|
|
|
|
|
return IconBtnDeleteWidget::create(['url' => '/admin/{slug}/delete/' . $row['id']])->run();
|
|
|
|
|
});
|
|
|
|
|
$table->create();
|
|
|
|
|
$table->render();
|