feat: add slug field to events and implement tests for slug uniqueness per tenant
This commit is contained in:
@@ -11,14 +11,14 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('events', function (Blueprint $table): void {
|
||||
$table->string('slug')->nullable()->after('tenant_code');
|
||||
$table->string('slug')->nullable();
|
||||
});
|
||||
|
||||
$usedSlugsByTenant = [];
|
||||
|
||||
foreach (DB::table('events')->orderBy('tenant_code')->orderBy('id')->get() as $event) {
|
||||
$baseSlug = Str::slug((string) $event->title);
|
||||
$baseSlug = $baseSlug !== '' ? mb_substr($baseSlug, 0, 240) : 'evento-'.$event->id;
|
||||
$baseSlug = $baseSlug !== '' ? substr($baseSlug, 0, 240) : 'evento-'.$event->id;
|
||||
$slug = $baseSlug;
|
||||
$suffix = 2;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user