55 lines
1.8 KiB
PHP
55 lines
1.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @var \Illuminate\Database\Eloquent\Collection $user
|
|
*/
|
|
|
|
use app\models\User;
|
|
use Itguild\EloquentTable\ViewEloquentTable;
|
|
use Itguild\EloquentTable\ViewJsonTableEloquentModel;
|
|
use kernel\IGTabel\btn\DangerBtn;
|
|
use kernel\IGTabel\btn\PrimaryBtn;
|
|
use kernel\IGTabel\btn\SuccessBtn;
|
|
|
|
//$dataProvider = new ViewJsonTableEloquentModel($user, [
|
|
// 'params' => ["class" => "table table-bordered", "border" => "2"],
|
|
// 'baseUrl' => "/admin/user",
|
|
//]);
|
|
//$table = new ViewJsonTable($dataProvider->getJson());
|
|
//$table->beforeTable(function () use ($user) {
|
|
// $btn = PrimaryBtn::create("Список", "/admin/user")->fetch();
|
|
// $btn .= SuccessBtn::create("Редактировать", "/admin/user/update/" . $user->id)->fetch();
|
|
// $btn .= DangerBtn::create("Удалить", "/admin/user/delete/" . $user->id)->fetch();
|
|
// return $btn;
|
|
//});
|
|
//$table->create();
|
|
//$table->render();
|
|
|
|
$table = new ViewEloquentTable(new ViewJsonTableEloquentModel($user, [
|
|
'params' => ["class" => "table table-bordered", "border" => "2"],
|
|
'baseUrl' => "/admin/user",
|
|
]));
|
|
$table->beforePrint(function () use ($user) {
|
|
$btn = PrimaryBtn::create("Список", "/admin/user")->fetch();
|
|
$btn .= SuccessBtn::create("Редактировать", "/admin/user/update/" . $user->id)->fetch();
|
|
$btn .= DangerBtn::create("Удалить", "/admin/user/delete/" . $user->id)->fetch();
|
|
return $btn;
|
|
});
|
|
$table->rows([
|
|
'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->create();
|
|
$table->render(); |