Tag blog posts and sign them with a member
Some checks failed
Tests / lint (push) Has been cancelled
Tests / test (push) Has been cancelled
Tests / test-postgres (push) Has been cancelled
Tests / mcp (push) Has been cancelled

Tags are named in every language and made from the page form; the byline is
the member who signs a post on the site. The public API sends both, filters
posts by tag and lists the tags in use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 11:01:18 +02:00
parent 6fc600e6a1
commit 9f970808ca
27 changed files with 809 additions and 12 deletions

View File

@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace Database\Factories;
use App\Models\Tag;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<Tag>
*/
class TagFactory extends Factory
{
public function definition(): array
{
$name = $this->faker->unique()->word();
return [
'name' => ['es' => $name, 'en' => $name, 'ca' => $name],
'slug' => ['es' => Str::slug($name), 'en' => Str::slug($name), 'ca' => Str::slug($name)],
];
}
}

View File

@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* For the blog: tags to group posts by subject, and a byline — the member who
* signs a post, which is not always the account that typed it in.
*/
return new class extends Migration
{
public function up(): void
{
Schema::create('tags', function (Blueprint $table): void {
$table->id();
$table->jsonb('name');
$table->jsonb('slug');
$table->timestamps();
});
Schema::create('page_tag', function (Blueprint $table): void {
$table->foreignId('page_id')->constrained()->cascadeOnDelete();
$table->foreignId('tag_id')->constrained()->cascadeOnDelete();
$table->primary(['page_id', 'tag_id']);
});
Schema::table('pages', function (Blueprint $table): void {
$table->foreignId('byline_member_id')->nullable()->after('author_id')->constrained('members')->nullOnDelete();
});
}
public function down(): void
{
Schema::table('pages', function (Blueprint $table): void {
$table->dropConstrainedForeignId('byline_member_id');
});
Schema::dropIfExists('page_tag');
Schema::dropIfExists('tags');
}
};