From c0bedcb5ee7083e630637cd25ebbcc37c0fa4715 Mon Sep 17 00:00:00 2001 From: stasbilay02 Date: Tue, 3 Dec 2024 10:51:22 +0300 Subject: [PATCH] add additional property to user --- kernel/modules/user/views/form.php | 5 +++++ kernel/modules/user/views/index.php | 10 ++++++++++ kernel/modules/user/views/view.php | 9 +++++++++ 3 files changed, 24 insertions(+) diff --git a/kernel/modules/user/views/form.php b/kernel/modules/user/views/form.php index 8c49d1e..66ce4d5 100644 --- a/kernel/modules/user/views/form.php +++ b/kernel/modules/user/views/form.php @@ -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); ?>
diff --git a/kernel/modules/user/views/index.php b/kernel/modules/user/views/index.php index ef5976c..e492f5e 100644 --- a/kernel/modules/user/views/index.php +++ b/kernel/modules/user/views/index.php @@ -24,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" => [ diff --git a/kernel/modules/user/views/view.php b/kernel/modules/user/views/view.php index 5cab5ea..856186f 100644 --- a/kernel/modules/user/views/view.php +++ b/kernel/modules/user/views/view.php @@ -25,6 +25,15 @@ $table->beforePrint(function () use ($user) { 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){