igfs/kernel/modules/user/views/view.php
2024-11-20 12:56:15 +03:00

45 lines
1.3 KiB
PHP

<?php
/**
* @var \Illuminate\Database\Eloquent\Collection $user
*/
use kernel\modules\user\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;
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnListWidget;
$table = new ViewEloquentTable(new ViewJsonTableEloquentModel($user, [
'params' => ["class" => "table table-bordered", "border" => "2"],
'baseUrl' => "/admin/user",
]));
$table->beforePrint(function () use ($user) {
$btn = IconBtnListWidget::create(['url' => '/admin/user'])->run();
$btn .= IconBtnEditWidget::create(['url' => '/admin/user/update/' . $user->id])->run();
$btn .= IconBtnDeleteWidget::create(['url' => '/admin/user/delete/' . $user->id])->run();
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();