Schema and storage
The package registers a translatable() Blueprint macro that creates a jsonb column. Use it in your own migrations:
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
Schema::create('topics', function (Blueprint $table): void {
$table->id();
$table->translatable('name'); // jsonb column
$table->translatable('description')->nullable();
$table->localizedSlug('slug'); // sluggable's macro — jsonb / json / text per engine
$table->timestamps();
});The macro is registered in the provider’s register() phase, so it’s available to every migration. localizedSlug() is sluggable’s macro for per-locale slug columns.
Storage format
Each attribute holds a plain JSON object keyed by locale — no vendor wrapper:
{"en": "Investing", "sk": "Investovanie"}Blank and null values are never stored, and an attribute with no translations is written as an empty object. Rows written by the hand-rolled “json cast + locale accessor” pattern read back identically, so there is no data migration when adopting this package. Adding a locale later is a config change — the map simply gains a key.
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.