diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php
index e97aabd..a478284 100644
--- a/app/controllers/UserController.php
+++ b/app/controllers/UserController.php
@@ -75,20 +75,21 @@ class UserController extends Controller{
if (!$user){
throw new Exception(message: "The user not found");
}
- $this->twig->addFunction(new TwigFunction('table', function () use ($user){
- $dataProvider = new ViewJsonTableEloquentModel($user, [
- 'params' => ["class" => "table table-bordered", "border" => "2"],
- 'baseUrl' => "/admin/user",
- ]);
- $table = new ViewJsonTable($dataProvider->getJson());
- $table->beforeTable(function (){
- return PrimaryBtn::create("Список", "/admin/user")->fetch();
- });
- $table->create();
- $table->render();
- }));
-
- echo $this->twig->render('user_table.html.twig');
+// $this->twig->addFunction(new TwigFunction('table', function () use ($user){
+// $dataProvider = new ViewJsonTableEloquentModel($user, [
+// 'params' => ["class" => "table table-bordered", "border" => "2"],
+// 'baseUrl' => "/admin/user",
+// ]);
+// $table = new ViewJsonTable($dataProvider->getJson());
+// $table->beforeTable(function (){
+// return PrimaryBtn::create("Список", "/admin/user")->fetch();
+// });
+// $table->create();
+// $table->render();
+// }));
+//
+// echo $this->twig->render('user_table.html.twig');
+ $this->cgView->render("user/view.php", ['user' => $user]);
}
/**
@@ -98,7 +99,7 @@ class UserController extends Controller{
*/
public function actionUpdate($id): void
{
- echo $this->twig->render('user_update.html.twig');
+ $this->cgView->render("user/form.php");
}
public function actionEdit($id): void
@@ -135,6 +136,8 @@ class UserController extends Controller{
public function actionDelete($id): void
{
User::find($id)->delete();
+ $this->redirect("/admin/user/");
+
}
}
\ No newline at end of file
diff --git a/kernel/IGTabel/btn/PrimaryBtn.php b/kernel/IGTabel/btn/PrimaryBtn.php
index f4312c4..31a43c3 100644
--- a/kernel/IGTabel/btn/PrimaryBtn.php
+++ b/kernel/IGTabel/btn/PrimaryBtn.php
@@ -8,7 +8,7 @@ class PrimaryBtn
public function __construct(string $title, string $url)
{
- $this->btn = "$title";
+ $this->btn = "$title";
}
public function fetch(): string
diff --git a/views/admin/user/view.php b/views/admin/user/view.php
new file mode 100644
index 0000000..67e93d3
--- /dev/null
+++ b/views/admin/user/view.php
@@ -0,0 +1,22 @@
+ ["class" => "table table-bordered", "border" => "2"],
+ 'baseUrl' => "/admin/user",
+]);
+$table = new ViewJsonTable($dataProvider->getJson());
+$table->beforeTable(function () use ($user) {
+ $btn = PrimaryBtn::create("Список", "/admin/user")->fetch();
+ $btn .= PrimaryBtn::create("Редактировать", "/admin/user/update/" . $user->id)->fetch();
+ $btn .= PrimaryBtn::create("Удалить", "/admin/user/delete/" . $user->id)->fetch();
+ return $btn;
+});
+$table->create();
+$table->render();
\ No newline at end of file