---
title: "Schema and storage — Translatable for Laravel | Roundly"
description: "Add jsonb locale-map columns with the translatable() Blueprint macro; values are stored as a plain JSON object with no wrapper."
url: https://roundly-consulting.com/open-source/docs/translatable-for-laravel/schema
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Translatable for Laravel](https://roundly-consulting.com/open-source/docs/translatable-for-laravel.md)

# Schema and storage

The package registers a translatable() Blueprint macro that creates a jsonb column. Use it in your own migrations:

```php
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.

## Static analysis

The macro is declared for Larastan / PHPStan as translatable(string $name): ColumnDefinition, so chained modifiers such as ->nullable() type-check. A macro exists only once its service provider has run. Larastan boots an auto-discovering host app and usually finds it, but not when the provider isn’t loaded during analysis — package development under Testbench, dont-discover, a provider registered by hand. There, a migration calling the macro would fail with “Call to an undefined method”. The package ships a PHPStan extension (RoundlyConsulting\\Translatable\\PHPStan\\TranslatableMacrosExtension) that phpstan/extension-installer loads through extra.phpstan.includes — nothing to configure. Without the installer, include it yourself:

```yaml
includes:
    - vendor/roundly-consulting/translatable-for-laravel/extension.neon
```

localizedSlug() is declared by sluggable’s own PHPStan extension.

## Storage format

Each attribute holds a plain JSON object keyed by locale — no vendor wrapper:

```json
{"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 crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## 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.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/translatable-for-laravel.md)
