baseline
This commit is contained in:
41
pages/admin/permissions/data().php
Normal file
41
pages/admin/permissions/data().php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use MintyPHP\Router;
|
||||
use MintyPHP\Support\Guard;
|
||||
use MintyPHP\Service\PermissionService;
|
||||
|
||||
Guard::requireLogin();
|
||||
Guard::requirePermission(PermissionService::PERMISSIONS_VIEW);
|
||||
if (!isset($_SESSION['user'])) {
|
||||
http_response_code(401);
|
||||
Router::json(['data' => [], 'total' => 0]);
|
||||
}
|
||||
|
||||
$limit = (int) ($_GET['limit'] ?? 10);
|
||||
$offset = (int) ($_GET['offset'] ?? 0);
|
||||
$search = trim((string) ($_GET['search'] ?? ''));
|
||||
$order = (string) ($_GET['order'] ?? 'key');
|
||||
$dir = (string) ($_GET['dir'] ?? 'asc');
|
||||
|
||||
$result = PermissionService::listPaged([
|
||||
'limit' => $limit,
|
||||
'offset' => $offset,
|
||||
'search' => $search,
|
||||
'order' => $order,
|
||||
'dir' => $dir,
|
||||
]);
|
||||
|
||||
$rows = [];
|
||||
foreach ($result['data'] ?? [] as $row) {
|
||||
$rows[] = [
|
||||
'id' => $row['id'] ?? null,
|
||||
'key' => $row['key'] ?? '',
|
||||
'description' => $row['description'] ?? '',
|
||||
'created' => dt($row['created'] ?? ''),
|
||||
];
|
||||
}
|
||||
|
||||
Router::json([
|
||||
'data' => $rows,
|
||||
'total' => $result['total'] ?? 0,
|
||||
]);
|
||||
Reference in New Issue
Block a user