Preparing database migration

Laravel I18n package store the translations of your model in another database table.

First, let's take a look at the example below. In this example, we will create a Product resource which translatable into several languages.

Schema::create('products', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->string('name');
    $table->boolean('published');
    $table->timestamps();
});

Schema::create('product_translations', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->bigInteger('product_id');
    $table->string('locale', 8);
    $table->string('description', 512)->nullable();
    $table->text('details')->nullable();

    $table->foreign('product_id')
          ->references('id')->on('products')
          ->onDelete('cascade');
});
Edit this page on GitHub Updated at Wed, May 25, 2022