add test batches

This commit is contained in:
root
2026-06-08 23:45:55 -04:00
parent c792b8be05
commit 8d4d610b82
1480 changed files with 22587 additions and 10762 deletions
@@ -6,10 +6,13 @@ use App\Models\NavItem;
use App\Models\Role;
use App\Models\RoleNavItem;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class NavBuilderService
{
public function __construct(private NavbarService $navbarService) {}
public function __construct(private NavbarService $navbarService)
{
}
public function getAdminPayload(): array
{
@@ -74,7 +77,7 @@ class NavBuilderService
$menuParentId = null;
}
if ($menuParentId !== null && ! NavItem::query()->whereKey($menuParentId)->exists()) {
if ($menuParentId !== null && !NavItem::query()->whereKey($menuParentId)->exists()) {
return ['ok' => false, 'message' => 'Selected parent does not exist.'];
}
@@ -85,7 +88,7 @@ class NavBuilderService
'icon_class' => trim((string) ($payload['icon_class'] ?? '')) ?: null,
'target' => trim((string) ($payload['target'] ?? '')) ?: null,
'sort_order' => (int) ($payload['sort_order'] ?? 0),
'is_enabled' => ! empty($payload['is_enabled']) ? 1 : 0,
'is_enabled' => !empty($payload['is_enabled']) ? 1 : 0,
];
$roleIds = array_values(array_unique(array_filter(
@@ -187,7 +190,7 @@ class NavBuilderService
}
$roleId = (int) ($row['role_id'] ?? 0);
$roleName = $row['role_name'] ?? ($roleId ? ('#'.$roleId) : null);
$roleName = $row['role_name'] ?? ($roleId ? ('#' . $roleId) : null);
if ($roleId > 0) {
$roleAssignments[$navId]['ids'][] = $roleId;
@@ -223,7 +226,7 @@ class NavBuilderService
],
];
if (! empty($node['children'])) {
if (!empty($node['children'])) {
$output = array_merge($output, $this->flattenTreeForResponse($node['children'], $roleAssignments, $depth + 1));
}
}
@@ -236,7 +239,6 @@ class NavBuilderService
$s = trim(preg_replace('/\s+/', ' ', $s));
$s = preg_replace('/^[^[:alnum:]]+/u', '', $s);
$s = preg_replace('/^(?i)(the|an|a)\s+/', '', $s);
return mb_strtolower($s, 'UTF-8');
}
@@ -248,7 +250,7 @@ class NavBuilderService
return $result !== 0 ? $result : ((int) ($a['id'] ?? 0) <=> (int) ($b['id'] ?? 0));
});
foreach ($nodes as &$node) {
if (! empty($node['children'])) {
if (!empty($node['children'])) {
$this->sortTreeAlpha($node['children']);
}
}