2025-01-03 02:11:09 +03:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var \Illuminate\Database\Eloquent\Collection $card
|
|
|
|
|
* @var int $page_number
|
|
|
|
|
* @var \kernel\CgView $view
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
use kernel\app_modules\card\models\Card;
|
|
|
|
|
use Itguild\EloquentTable\EloquentDataProvider;
|
|
|
|
|
use Itguild\EloquentTable\ListEloquentTable;
|
|
|
|
|
use kernel\modules\user\models\User;
|
|
|
|
|
use kernel\widgets\IconBtn\IconBtnCreateWidget;
|
|
|
|
|
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
|
|
|
|
|
use kernel\widgets\IconBtn\IconBtnEditWidget;
|
|
|
|
|
use kernel\widgets\IconBtn\IconBtnViewWidget;
|
|
|
|
|
|
|
|
|
|
$view->setTitle("Список card");
|
|
|
|
|
$view->setMeta([
|
|
|
|
|
'description' => 'Список card системы'
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//Для использования таблицы с моделью, необходимо создать таблицу в базе данных
|
2025-01-27 11:57:28 +03:00
|
|
|
|
$table = new ListEloquentTable(new EloquentDataProvider(Card::query()->orderBy("id", "DESC"), [
|
2025-01-03 02:11:09 +03:00
|
|
|
|
'currentPage' => $page_number,
|
|
|
|
|
'perPage' => 8,
|
|
|
|
|
'params' => ["class" => "table table-bordered", "border" => "2"],
|
2025-01-27 12:35:25 +03:00
|
|
|
|
'baseUrl' => "/admin/card",
|
|
|
|
|
'fillable' => [
|
|
|
|
|
'user_id',
|
|
|
|
|
'balance',
|
|
|
|
|
'username',
|
|
|
|
|
'card_template_id',
|
|
|
|
|
'card_file_id',
|
|
|
|
|
'status',
|
|
|
|
|
],
|
2025-01-03 02:11:09 +03:00
|
|
|
|
]));
|
|
|
|
|
|
|
|
|
|
$table->columns([
|
|
|
|
|
'user_id' => [
|
|
|
|
|
'value' => function ($data) {
|
|
|
|
|
return User::find($data)->username ?? '';
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
'card_template_id' => [
|
|
|
|
|
'value' => function ($data) {
|
|
|
|
|
return \kernel\app_modules\card\models\CardTemplate::find($data)->title;
|
|
|
|
|
}
|
|
|
|
|
],
|
2025-01-27 12:35:25 +03:00
|
|
|
|
"username" => [
|
|
|
|
|
"filter" => [
|
|
|
|
|
"class" => \Itguild\Tables\Filter\InputTextFilter::class
|
|
|
|
|
]
|
|
|
|
|
],
|
2025-01-03 02:11:09 +03:00
|
|
|
|
'card_file_id' => [
|
|
|
|
|
'value' => function ($data) {
|
|
|
|
|
$file = \kernel\app_modules\card\models\CardFile::find($data)->file;
|
|
|
|
|
return $file ? \kernel\helpers\Html::img($file) : "";
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
'status' => [
|
|
|
|
|
'value' => function ($data) {
|
|
|
|
|
return Card::getStatus()[$data];
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
//$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' => [],
|
|
|
|
|
// ]
|
|
|
|
|
//));
|
|
|
|
|
|
|
|
|
|
$table->beforePrint(function () {
|
|
|
|
|
return IconBtnCreateWidget::create(['url' => '/admin/card/create'])->run();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$table->addAction(function($row) {
|
|
|
|
|
return IconBtnViewWidget::create(['url' => '/admin/card/' . $row['id']])->run();
|
|
|
|
|
});
|
|
|
|
|
$table->addAction(function($row) {
|
|
|
|
|
return IconBtnEditWidget::create(['url' => '/admin/card/update/' . $row['id']])->run();
|
|
|
|
|
});
|
|
|
|
|
$table->addAction(function($row) {
|
|
|
|
|
return IconBtnDeleteWidget::create(['url' => '/admin/card/delete/' . $row['id']])->run();
|
|
|
|
|
});
|
|
|
|
|
$table->create();
|
|
|
|
|
$table->render();
|