diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php index 91aa250..4e2b20b 100644 --- a/app/controllers/UserController.php +++ b/app/controllers/UserController.php @@ -61,9 +61,7 @@ class UserController extends Controller{ */ public function actionIndex(): void { -// $users = User::where(['role' => 1])->get(); $users = User::all(); - //App::$header->add("asd", "asd"); $this->cgView->render("user/index.php", ['users' => $users]); } diff --git a/composer.lock b/composer.lock index b463373..52bbb23 100644 --- a/composer.lock +++ b/composer.lock @@ -851,11 +851,11 @@ }, { "name": "itguild/tables", - "version": "0.1.6", + "version": "0.1.7", "source": { "type": "git", "url": "https://git.itguild.info/ItGuild/tables", - "reference": "48e6d645d97ace1eec258819da758f53db0b7d46" + "reference": "b7fea4122c25d8ba9eafd58c07d65e829ea4c383" }, "type": "library", "autoload": { @@ -873,7 +873,7 @@ "email": "apuc06@mail.ru" } ], - "time": "2024-07-23T12:17:16+00:00" + "time": "2024-07-30T09:20:16+00:00" }, { "name": "madesimple/php-arrays", diff --git a/kernel/App.php b/kernel/App.php index 582836b..a542a2a 100644 --- a/kernel/App.php +++ b/kernel/App.php @@ -22,8 +22,9 @@ class App { $dispatcher = new Dispatcher(App::$collector->getData()); $response = $dispatcher->dispatch($_SERVER['REQUEST_METHOD'], parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)); - //header('Content-Type: ' . App::$responseType); App::$header->set(); + + //header('Content-Type: ' . App::$responseType); echo $response; } diff --git a/kernel/Header.php b/kernel/Header.php index 12afd12..2a706ce 100755 --- a/kernel/Header.php +++ b/kernel/Header.php @@ -11,14 +11,14 @@ namespace kernel; class Header { - protected $list = []; + protected array $list = []; - public function add($key, $value) + public function add($key, $value): void { $this->list[$key] = $value; } - public function set() + public function set(): void { foreach ($this->list as $key=>$v){ header($key . ": " . $v); diff --git a/views/admin/user/index.php b/views/admin/user/index.php index 79e5da6..5ec6f5c 100644 --- a/views/admin/user/index.php +++ b/views/admin/user/index.php @@ -19,10 +19,15 @@ $dataProvider = new ListJsonTableEloquentCollection($users, [ 'baseUrl' => "/admin/user", ]); $table = new ListJsonTable($dataProvider->getJson()); -$table->beforePrint(function (){ +$table->beforePrint(function () { return PrimaryBtn::create("Создать", "/admin/user/create")->fetch(); //return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch(); }); +$table->afterPrint(function () use ($users) { + $pagination = new \Itguild\Tables\Pagination($users->count(), 5, 1, "/admin/user/"); + $pagination->create(); + return $pagination->fetch(); +}); $table->addAction(UserViewActionColumn::class); $table->addAction(UserEditActionColumn::class); $table->addAction(UserDeleteActionColumn::class);