Skip to content
Phillip Dornauer edited this page Apr 1, 2026 · 1 revision

Search

Marble includes full-text search over published content.

Frontend Search

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.

How It Works

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.

Search Form

<form action="/search" method="GET">
    <input type="search" name="q" placeholder="Search…" value="{{ request('q') }}">
    <button type="submit">Search</button>
</form>

Custom Search Logic

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();

Clone this wiki locally