kernel update
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
use kernel\modules\user\models\User;
|
||||
|
||||
$form = new \itguild\forms\ActiveForm();
|
||||
$form->beginForm(isset($model) ? "/admin/user/edit/" . $model->id : "/admin/user");
|
||||
$form->beginForm(isset($model) ? "/admin/user/edit/" . $model->id : "/admin/user", enctype: 'multipart/form-data');
|
||||
|
||||
$form->field(class: \itguild\forms\inputs\TextInput::class, name: "username", params: [
|
||||
'class' => "form-control",
|
||||
@ -32,6 +32,11 @@ $form->field(class: \itguild\forms\inputs\TextInput::class, name: "email", param
|
||||
->setLabel("Email")
|
||||
->render();
|
||||
|
||||
$entityRelations = new \kernel\EntityRelation();
|
||||
if (!isset($model)) {
|
||||
$model = new User();
|
||||
}
|
||||
$entityRelations->renderEntityAdditionalPropertyFormBySlug("user", $model);
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
|
@ -12,6 +12,10 @@ use kernel\IGTabel\action_column\EditActionColumn;
|
||||
use kernel\IGTabel\action_column\ViewActionColumn;
|
||||
use kernel\IGTabel\btn\PrimaryBtn;
|
||||
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;
|
||||
|
||||
$table = new ListEloquentTable(new EloquentDataProvider(User::class, [
|
||||
'currentPage' => $page_number,
|
||||
@ -20,6 +24,16 @@ $table = new ListEloquentTable(new EloquentDataProvider(User::class, [
|
||||
'baseUrl' => "/admin/user",
|
||||
'filters' => ['email'],
|
||||
]));
|
||||
|
||||
$entityRelation = new \kernel\EntityRelation();
|
||||
$additionals = $entityRelation->getEntityRelationsBySlug("user");
|
||||
|
||||
foreach ($additionals as $additional) {
|
||||
$table->addColumn($additional, $additional, function ($id) use ($entityRelation, $additional) {
|
||||
return $entityRelation->getAdditionalPropertyByEntityId("user", $id, $additional);
|
||||
});
|
||||
}
|
||||
|
||||
$table->columns([
|
||||
'username' => [
|
||||
"filter" => [
|
||||
@ -42,11 +56,16 @@ $table->columns([
|
||||
}
|
||||
]);
|
||||
$table->beforePrint(function () {
|
||||
return PrimaryBtn::create("Создать", "/admin/user/create")->fetch();
|
||||
//return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch();
|
||||
return IconBtnCreateWidget::create(['url' => '/admin/user/create'])->run();
|
||||
});
|
||||
$table->addAction(function($row) {
|
||||
return IconBtnViewWidget::create(['url' => '/admin/user/view/' . $row['id']])->run();
|
||||
});
|
||||
$table->addAction(function($row) {
|
||||
return IconBtnEditWidget::create(['url' => '/admin/user/update/' . $row['id']])->run();
|
||||
});
|
||||
$table->addAction(function($row) {
|
||||
return IconBtnDeleteWidget::create(['url' => '/admin/user/delete/' . $row['id']])->run();
|
||||
});
|
||||
$table->addAction(ViewActionColumn::class);
|
||||
$table->addAction(EditActionColumn::class);
|
||||
$table->addAction(DeleteActionColumn::class);
|
||||
$table->create();
|
||||
$table->render();
|
@ -10,17 +10,30 @@ 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 = PrimaryBtn::create("Список", "/admin/user")->fetch();
|
||||
$btn .= SuccessBtn::create("Редактировать", "/admin/user/update/" . $user->id)->fetch();
|
||||
$btn .= DangerBtn::create("Удалить", "/admin/user/delete/" . $user->id)->fetch();
|
||||
$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;
|
||||
});
|
||||
|
||||
$entityRelation = new \kernel\EntityRelation();
|
||||
$additionals = $entityRelation->getEntityAdditionalProperty("user", $user);
|
||||
|
||||
foreach ($additionals as $key => $additional) {
|
||||
$table->addRow($key, function () use ($additional) {
|
||||
return $additional;
|
||||
}, ['after' => 'email']);
|
||||
}
|
||||
|
||||
$table->rows([
|
||||
'created_at' => function ($data) {
|
||||
if (!$data){
|
||||
|
Reference in New Issue
Block a user