-
Notifications
You must be signed in to change notification settings - Fork 0
Search
Phillip Dornauer edited this page Apr 1, 2026
·
1 revision
Marble includes full-text search over published content.
The demo app ships a SearchController at app/Http/Controllers/SearchController.php with a route:
GET /search?q=your+query
Results are rendered in resources/views/marble-pages/search.blade.php.
The controller queries the item_values table for field values matching the search term (SQL LIKE). Results are filtered to published items only. The view highlights matching keywords with <mark> tags.
<form action="/search" method="GET">
<input type="search" name="q" placeholder="Search…" value="{{ request('q') }}">
<button type="submit">Search</button>
</form>Create your own controller and register the route before Marble::routes():
// routes/web.php
Route::get('/search', [MySearchController::class, 'index']);
Marble::routes(...);Example controller:
use Marble\Admin\Models\ItemValue;
use Marble\Admin\Models\Item;
$query = request('q');
$itemIds = ItemValue::where('value', 'LIKE', "%{$query}%")
->pluck('item_id')
->unique();
$results = Item::whereIn('id', $itemIds)
->where('status', 'published')
->get();