@if($search) {!! $this->highlightSearch($post->title, $search) !!} @else {{ $post->title }} @endif
@if($search) {!! $this->highlightSearch($post->excerpt, $search) !!} @else {{ $post->excerpt }} @endif
{{ __('posts.read_more') }} →# Story 5.5: Post Search ## Epic Reference **Epic 5:** Posts/Blog System ## User Story As a **website visitor**, I want **to search through blog posts**, So that **I can find relevant legal articles and information**. ## Story Context ### Existing System Integration - **Integrates with:** posts table, public posts listing - **Technology:** Livewire Volt with real-time search - **Follows pattern:** Search component pattern - **Touch points:** Posts listing page ## Acceptance Criteria ### Search Functionality - [ ] Search input on posts listing page - [ ] Search by title (both languages) - [ ] Search by body content (both languages) - [ ] Real-time search results (debounced) ### User Experience - [ ] "No results found" message when empty - [ ] Clear search button - [ ] Search works in both Arabic and English - [ ] Only searches published posts ### Optional Enhancements - [ ] Search highlights in results - [ ] Search suggestions ### Quality Requirements - [ ] Debounce to reduce server load (300ms) - [ ] Case-insensitive search - [ ] Tests for search functionality ## Technical Notes ### Updated Posts Index Component ```php resetPage(); } public function clearSearch(): void { $this->search = ''; $this->resetPage(); } public function with(): array { return [ 'posts' => Post::published() ->when($this->search, function ($query) { $search = $this->search; $query->where(function ($q) use ($search) { $q->where('title_ar', 'like', "%{$search}%") ->orWhere('title_en', 'like', "%{$search}%") ->orWhere('body_ar', 'like', "%{$search}%") ->orWhere('body_en', 'like', "%{$search}%"); }); }) ->latest() ->paginate(10), ]; } }; ?>
@if($posts->total() > 0) {{ __('posts.search_results', ['count' => $posts->total(), 'query' => $search]) }} @else {{ __('posts.no_results', ['query' => $search]) }} @endif
@endif@if($search) {!! $this->highlightSearch($post->excerpt, $search) !!} @else {{ $post->excerpt }} @endif
{{ __('posts.read_more') }} →{{ __('posts.no_results', ['query' => $search]) }}
{{ __('posts.no_posts') }}
@endif