Beartropy Tables
Authentication required
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
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