btn
This commit is contained in:
parent
f005cb357b
commit
4d922096a9
@ -75,20 +75,21 @@ class UserController extends Controller{
|
|||||||
if (!$user){
|
if (!$user){
|
||||||
throw new Exception(message: "The user not found");
|
throw new Exception(message: "The user not found");
|
||||||
}
|
}
|
||||||
$this->twig->addFunction(new TwigFunction('table', function () use ($user){
|
// $this->twig->addFunction(new TwigFunction('table', function () use ($user){
|
||||||
$dataProvider = new ViewJsonTableEloquentModel($user, [
|
// $dataProvider = new ViewJsonTableEloquentModel($user, [
|
||||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
// 'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||||
'baseUrl' => "/admin/user",
|
// 'baseUrl' => "/admin/user",
|
||||||
]);
|
// ]);
|
||||||
$table = new ViewJsonTable($dataProvider->getJson());
|
// $table = new ViewJsonTable($dataProvider->getJson());
|
||||||
$table->beforeTable(function (){
|
// $table->beforeTable(function (){
|
||||||
return PrimaryBtn::create("Список", "/admin/user")->fetch();
|
// return PrimaryBtn::create("Список", "/admin/user")->fetch();
|
||||||
});
|
// });
|
||||||
$table->create();
|
// $table->create();
|
||||||
$table->render();
|
// $table->render();
|
||||||
}));
|
// }));
|
||||||
|
//
|
||||||
echo $this->twig->render('user_table.html.twig');
|
// 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
|
public function actionUpdate($id): void
|
||||||
{
|
{
|
||||||
echo $this->twig->render('user_update.html.twig');
|
$this->cgView->render("user/form.php");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionEdit($id): void
|
public function actionEdit($id): void
|
||||||
@ -135,6 +136,8 @@ class UserController extends Controller{
|
|||||||
public function actionDelete($id): void
|
public function actionDelete($id): void
|
||||||
{
|
{
|
||||||
User::find($id)->delete();
|
User::find($id)->delete();
|
||||||
|
$this->redirect("/admin/user/");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -8,7 +8,7 @@ class PrimaryBtn
|
|||||||
|
|
||||||
public function __construct(string $title, string $url)
|
public function __construct(string $title, string $url)
|
||||||
{
|
{
|
||||||
$this->btn = "<a class='btn btn-primary' href='$url' style='margin: 3px; width: 100px;' >$title</a>";
|
$this->btn = "<a class='btn btn-primary' href='$url' style='margin: 3px; width: 150px;' >$title</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fetch(): string
|
public function fetch(): string
|
||||||
|
22
views/admin/user/view.php
Normal file
22
views/admin/user/view.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Illuminate\Database\Eloquent\Collection $user
|
||||||
|
*/
|
||||||
|
use Itguild\Tables\ViewJsonTable;
|
||||||
|
use kernel\IGTabel\btn\PrimaryBtn;
|
||||||
|
use kernel\IGTabel\ViewJsonTableEloquentModel;
|
||||||
|
|
||||||
|
$dataProvider = new ViewJsonTableEloquentModel($user, [
|
||||||
|
'params' => ["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();
|
Loading…
Reference in New Issue
Block a user