agent/php/Mod/Admin/Search/Providers/AdminPageSearchProvider.php
Snider f96bd67bd6 feat(agent/admin+hub): RFC foundation — admin scaffold + Hub global components
Foundation slice for Mantis #843 php/Mod/Admin + php/Website/Hub RFC:

* php/Mod/Admin/Boot.php — search registry, menu registry, form component
  layer, HasRateLimiting concern, reusable form/view primitives under
  Mod/Admin/Forms
* php/Website/Hub/Boot.php — host-aware Hub route naming for secondary
  domains
* WorkspaceSwitcher and GlobalSearch global Hub Livewire components
* Foundation routed slice in Hub/Routes/admin.php: dashboard shell,
  workspace listing, site settings (with WordPress/webhook connector),
  account usage, platform user list+detail
* Foundation tests under php/tests/Feature/Mod/Admin/

53 PHP files. php -l clean. Pest unrunnable in sandbox (no vendor/).

Foundation slice only — composer.json kept off-limits so namespace stays
under Core\Mod\Agentic\... rather than standalone Core\Admin package.
Deferred: Profile, Settings, ServiceManager, ServicesAdmin, Honeypot,
Entitlement\{Dashboard,FeatureManager,PackageManager}, PromptManager,
WaitlistManager, Console, Databases, Deployments, Content,
ContentManager, ContentEditor, ActivityLog, Analytics, AIServices,
BoostPurchase. Lane was under-instructed by supervisor with stop-at
framing — follow-up tickets needed for remainder.

Co-authored-by: Codex <noreply@openai.com>
Closes tasks.lthn.sh/view.php?id=843
2026-04-25 21:09:22 +01:00

105 lines
3.1 KiB
PHP

<?php
// SPDX-License-Identifier: EUPL-1.2
declare(strict_types=1);
namespace Core\Mod\Agentic\Mod\Admin\Search\Providers;
use Core\Mod\Agentic\Mod\Admin\Search\Contracts\SearchProvider;
use Core\Mod\Agentic\Mod\Admin\Search\SearchProviderRegistry;
use Core\Mod\Agentic\Mod\Admin\Search\SearchResult;
use Illuminate\Support\Facades\Route;
class AdminPageSearchProvider implements SearchProvider
{
public function __construct(
protected SearchProviderRegistry $registry
) {}
public function name(): string
{
return 'Pages';
}
public function icon(): string
{
return 'rectangle-stack';
}
public function priority(): int
{
return 10;
}
public function available(?object $user = null, ?object $workspace = null): bool
{
return $user !== null;
}
/**
* @return array<int, SearchResult>
*/
public function search(string $query): array
{
$pages = array_filter($this->pagesForCurrentUser(), function (array $page) use ($query): bool {
return $this->registry->fuzzyMatch($query, $page['title'])
|| $this->registry->fuzzyMatch($query, $page['description']);
});
usort($pages, fn (array $left, array $right): int => $this->registry->relevanceScore($query, $right['title']) <=> $this->registry->relevanceScore($query, $left['title']));
return array_map(static fn (array $page): SearchResult => SearchResult::fromArray($page), $pages);
}
/**
* @return array<int, array<string, string>>
*/
protected function pagesForCurrentUser(): array
{
$pages = [
[
'id' => 'dashboard',
'type' => 'admin_page',
'title' => 'Dashboard',
'description' => 'Hub landing page',
'url' => $this->safeRoute('hub.dashboard', '/hub'),
'icon' => 'house',
],
[
'id' => 'workspaces',
'type' => 'admin_page',
'title' => 'Workspaces',
'description' => 'Workspace and tenant registry',
'url' => $this->safeRoute('hub.sites', '/hub/workspaces'),
'icon' => 'folders',
],
[
'id' => 'usage',
'type' => 'admin_page',
'title' => 'Account Usage',
'description' => 'Storage, boosts and AI service usage',
'url' => $this->safeRoute('hub.account.usage', '/hub/account/usage'),
'icon' => 'chart-pie',
],
];
if (auth()->user()?->isHades()) {
$pages[] = [
'id' => 'platform',
'type' => 'admin_page',
'title' => 'Platform',
'description' => 'User search, tier management and verification',
'url' => $this->safeRoute('hub.platform', '/hub/platform'),
'icon' => 'server',
];
}
return $pages;
}
protected function safeRoute(string $name, string $fallback): string
{
return Route::has($name) ? route($name) : $fallback;
}
}