This repository has been archived on 2026-03-09. You can view files and clone it, but cannot push or open issues or pull requests.
php-mcp/src/Website/Mcp/View/Modal/UnifiedSearch.php
Snider 92e2097022
Some checks failed
CI / PHP 8.3 (push) Failing after 4s
CI / PHP 8.4 (push) Failing after 3s
fix: register MCP layout in layouts:: namespace
- Change <x-layouts.mcp> to <x-layouts::mcp> in all blade views
- Change Livewire #[Layout('components.layouts.mcp')] to layouts::mcp
- Register layouts path via Blade::anonymousComponentPath in Boot
- Layout file already exists at src/Front/View/Blade/layouts/mcp.blade.php

The dot notation couldn't resolve because mcp.blade.php lives in the
package, not the app's components directory. The layouts:: namespace
is the correct pattern matching core-php's component registration.

Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 15:38:27 +00:00

82 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace Core\Website\Mcp\View\Modal;
use Core\Search\Unified as UnifiedSearchService;
use Illuminate\Support\Collection;
use Livewire\Attributes\Layout;
use Livewire\Component;
/**
* Unified Search Component
*
* Single search interface across all system components:
* MCP tools, API endpoints, patterns, assets, todos, and plans.
*/
#[Layout('layouts::mcp')]
class UnifiedSearch extends Component
{
public string $query = '';
public array $selectedTypes = [];
public int $limit = 50;
protected UnifiedSearchService $searchService;
public function boot(UnifiedSearchService $searchService): void
{
$this->searchService = $searchService;
}
public function updatedQuery(): void
{
// Debounce handled by wire:model.debounce
}
public function toggleType(string $type): void
{
if (in_array($type, $this->selectedTypes)) {
$this->selectedTypes = array_values(array_diff($this->selectedTypes, [$type]));
} else {
$this->selectedTypes[] = $type;
}
}
public function clearFilters(): void
{
$this->selectedTypes = [];
}
public function getResultsProperty(): Collection
{
if (strlen($this->query) < 2) {
return collect();
}
return $this->searchService->search($this->query, $this->selectedTypes, $this->limit);
}
public function getTypesProperty(): array
{
return UnifiedSearchService::getTypes();
}
public function getResultCountsByTypeProperty(): array
{
if (strlen($this->query) < 2) {
return [];
}
$allResults = $this->searchService->search($this->query, [], 200);
return $allResults->groupBy('type')->map->count()->toArray();
}
public function render()
{
return view('mcp::web.unified-search');
}
}