-
Notifications
You must be signed in to change notification settings - Fork 0
Marble Facade API
All methods are available via Marble:: in Blade templates and PHP code.
use Marble\Admin\Facades\Marble;Registers the catch-all route. Place in routes/web.php after all custom routes.
Marble::routes(function ($item) {
return view(Marble::viewFor($item), ['item' => $item]);
});Returns the Blade view name for an item.
Get a single item by ID (cached).
Resolve a URL path to a published item.
Resolve a URL path or throw a 404.
Find an item by a field value.
$member = Marble::findItem('team_member', 'email', 'alice@example.com');Fluent query builder for items of a blueprint.
Marble::items('blog_post')
->published()
->under(10)
->orderBy('created_at', 'desc')
->paginate(10);Query methods:
| Method | Returns |
|---|---|
->published() |
Only published items |
->under(int $id) |
Only children of this item |
->orderBy($col, $dir) |
Sort |
->get() |
Collection |
->paginate(int $n) |
LengthAwarePaginator |
->first() |
Item|null |
->count() |
int |
->query() |
Eloquent Builder |
Marble::children($item) // all published children
Marble::children($item, 'blog_post') // filtered by blueprint
Marble::children($item, null, 'draft') // drafts only
Marble::children($item, null, 'all') // all statusesNavigation tree. Only published items with show_in_nav = true are included. Children available via $item->navChildren.
Without an argument, starts at the current site's root_item_id (fallback: config('marble.entry_item_id')). Pass an explicit ID to build a navigation from any subtree — useful for footer links, sidebar menus, etc.
Marble::navigation() // site root → main navigation
Marble::navigation(42) // subtree rooted at item 42
Marble::navigation(42, 1) // one level deep only
Marble::navigation(null, 2) // site root, max 2 levelsAncestor chain from root to item.
Marble::url($item) // current language
Marble::url($item, 'de') // German
Marble::url($item, 2) // by language IDActive site for current request.
Settings item for current site.
{{ Marble::settings()?->value('site_name') }}| Method | Description |
|---|---|
Marble::setLocale(string $code) |
Set language by code |
Marble::setLanguageById(int $id) |
Set language by ID |
Marble::currentLanguageId() |
Get current language ID |
Marble::primaryLanguageId() |
Get primary language ID |
| Method | Returns |
|---|---|
Marble::isPortalAuthenticated() |
bool |
Marble::portalUser() |
PortalUser|null |
Clear cache for item and all ancestors. Called automatically on save.
Register a custom field type. Call from a service provider's boot() method.
Marble::registerFieldType(new MyCustomFieldType());Get all registered field types.
Get a field type by identifier.
| Method | Returns | Description |
|---|---|---|
Marble::recordAbConversion(Item $item) |
void |
Record a conversion for the bucket the current visitor is assigned to |
Marble::activeVariantId() |
int|null |
ID of the active variant for the current request |
Marble::activeVariantItemId() |
int|null |
ID of the item the active variant belongs to |
Marble::setActiveVariantId(int $variantId, int $itemId) |
void |
Set by MarbleRouter during resolution — not for manual use |
Call this after the desired goal action in your own controller. Marble reads the visitor's marble_ab_{item_id} cookie and increments the correct conversion counter. No cookie = no-op.
// After a form submit, purchase, signup, etc.:
Marble::recordAbConversion($item);See A/B Testing for full details on conversion tracking and the sidebar widget.
A/B variant resolution happens automatically in MarbleRouter. Templates do not need to call these methods — $item->value() already returns the correct variant value.
Item subscriptions are managed in the admin UI (Watch/Unwatch button). No facade methods are needed in templates.
For custom notification dispatching from your own code, fire events or call notifySubscribers() on the item directly via the ItemSubscription model:
use Marble\Admin\Models\ItemSubscription;
$subscriberIds = $item->subscriberIds(); // Collection of user IDs