Beartropy Tables

Table State Handler
Persist user table preferences (column visibility, order) across sessions using database storage.

Authentication required

The State Handler stores preferences per-user in the database. It requires an authenticated user — enable it conditionally with Auth::check() to avoid errors for guests.

Setup

Publish the migration to create the required database table.

Publish & Run Migration

The State Handler requires the yat_user_table_config table. Publish and run the migration to create it.

1php artisan vendor:publish --provider="Beartropy\\Tables\\YATProvider" --tag="migrations"
2 
3php artisan migrate

One-time setup

This is the same migration from the Installation page. If you've already published and run it, skip this step.

Enable State Handler

Turn on state persistence in your table's settings() method.

Basic Enable

useStateHandler(bool $bool) — When enabled, the table saves and restores column visibility and order for each user.

1$this->useStateHandler(true);

Conditional Enable (Recommended)

Guard the state handler with Auth::check() to prevent errors when the table is accessible to guests.

1use Illuminate\Support\Facades\Auth;
2 
3$this->useStateHandler(Auth::check());

Custom Prefix

Differentiate state storage when using multiple tables.

Set Handler Prefix

setHandlerPrefix(string $prefix) — By default the table class name is used as the prefix. Override this to avoid conflicts when the same user interacts with multiple tables.

1$this->setHandlerPrefix('my_table_prefix');

When to use a custom prefix

Use custom prefixes when you have the same table component rendered in different contexts (e.g., an admin view and a user view) and want separate saved states for each.
Beartropy Logo

© 2026 Beartropy. All rights reserved.

Provided as-is, without warranty. Use at your own risk.