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

57 lines
1.7 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-11-20 12:45:02 +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-11-20 12:45:02 +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-11-20 12:45:02 +03:00
2024-12-03 10:51:22 +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([
2024-12-25 16:32:23 +03:00
'user_photo' => function ($data) {
return $data ? "<img src='$data' width='300px'>" : "";
},
2024-08-07 15:30:45 +03:00
'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();