This is my multilingual blog with categories and tags
php artisan make:model Post -m
php artisan make:model Category -m
php artisan make:model Tag -m
php artisan make:model Language -m
php artisan make:model PostTranslation -m
php artisan make:model CategoryTranslation -m
php artisan make:model TagTranslation -m
posts table:
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('picture')->nullable();
$table->date('date');
$table->timestamps();
});
categories table:
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
tags table:
Schema::create('tags', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
languages table:
Schema::create('languages', function (Blueprint $table) {
$table->id();
$table->string('code');
$table->string('name');
$table->timestamps();
});
post_translations table:
Schema::create('post_translations', function (Blueprint $table) {
$table->id();
$table->foreignId('post_id')->constrained()->onDelete('cascade');
$table->foreignId('language_id')->constrained()->onDelete('cascade');
$table->string('title');
$table->text('short_text');
$table->text('long_text');
$table->timestamps();
});
category_translations table:
Schema::create('category_translations', function (Blueprint $table) {
$table->id();
$table->foreignId('category_id')->constrained()->onDelete('cascade');
$table->foreignId('language_id')->constrained()->onDelete('cascade');
$table->string('name');
$table->timestamps();
});
tag_translations table:
Schema::create('tag_translations', function (Blueprint $table) {
$table->id();
$table->foreignId('tag_id')->constrained()->onDelete('cascade');
$table->foreignId('language_id')->constrained()->onDelete('cascade');
$table->string('name');
$table->timestamps();
});
if you like this approach i can send full code, categories and tags are like filter...