Where views are stored
Only the list of saved views is stored, never page content.
Browser (default)
'store' => 'browser',
The list lives in the browser tab's session storage. It clears when the tab closes. Nothing touches your server.
Database
'store' => 'database',
The list follows signed-in users across devices. Publish and run the migration first:
php artisan vendor:publish --tag="earmark-migrations"
php artisan migrate
- Signed-in users can choose whether their earmarks clear on logout (the default) or stay for next time.
- Guests keep their views for the session, and they move to the guest's account when they log in.
- Schedule pruning of expired guest views:
Schedule::command('model:prune', ['--model' => [\Pixelworxio\Earmark\Models\SavedView::class]])->daily();
The endpoints run behind the web middleware (sessions and CSRF), only touch the current user's or guest's own list, accept same-site paths only, and are rate limited.
Your own store
Register a store with load() and save(views):
Earmark.store('team', (settings) => ({
async load() {
return fetch('/team/earmarks').then((response) => response.json())
},
save(views) {
navigator.sendBeacon('/team/earmarks', JSON.stringify(views))
},
}))