igfs/kernel/modules/user/views/view.php

54 lines
1.6 KiB
PHP
Raw Normal View History

2024-07-25 11:55:31 +03:00
<?php
/**
* @var \Illuminate\Database\Eloquent\Collection $user
*/
2024-08-07 15:30:45 +03:00
2024-09-06 16:53:20 +03:00
use kernel\modules\user\models\User;
2024-08-07 15:30:45 +03:00
use Itguild\EloquentTable\ViewEloquentTable;
use Itguild\EloquentTable\ViewJsonTableEloquentModel;
2024-07-25 13:23:50 +03:00
use kernel\IGTabel\btn\DangerBtn;
2024-07-25 11:55:31 +03:00
use kernel\IGTabel\btn\PrimaryBtn;
2024-07-25 13:23:50 +03:00
use kernel\IGTabel\btn\SuccessBtn;
2024-12-16 14:26:13 +03:00
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnListWidget;
2024-07-25 11:55:31 +03:00
2024-08-07 15:30:45 +03:00
$table = new ViewEloquentTable(new ViewJsonTableEloquentModel($user, [
2024-07-25 11:55:31 +03:00
'params' => ["class" => "table table-bordered", "border" => "2"],
'baseUrl' => "/admin/user",
2024-08-07 15:30:45 +03:00
]));
$table->beforePrint(function () use ($user) {
2024-12-16 14:26:13 +03:00
$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();
2024-07-25 11:55:31 +03:00
return $btn;
});
2024-12-16 14:26:13 +03:00
$entityRelation = new \kernel\EntityRelation();
$additionals = $entityRelation->getEntityAdditionalProperty("user", $user);
foreach ($additionals as $key => $additional) {
$table->addRow($key, function () use ($additional) {
return $additional;
}, ['after' => 'email']);
}
2024-08-07 15:30:45 +03:00
$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");
}
]);
2024-07-25 11:55:31 +03:00
$table->create();
$table->render();