error('img-confirm-v1 fehlt — zuerst LegalTextSeeder ausführen.'); return self::FAILURE; } $query = PressReleaseImage::query() ->withTrashed() ->whereNotNull('rights_confirmed_at') ->whereDoesntHave('rightsConfirmations') ->with('pressRelease'); $count = $query->count(); $this->info("Bilder mit alter Bestätigung ohne Protokoll: {$count}"); if ($this->option('dry-run') || $count === 0) { return self::SUCCESS; } $written = 0; $query->chunkById(200, function ($images) use ($text, &$written): void { foreach ($images as $image) { ImageRightsConfirmation::query()->create([ 'subject_type' => $image->getMorphClass(), 'subject_id' => $image->getKey(), 'press_release_id' => $image->press_release_id, 'company_id' => $image->pressRelease?->company_id, 'user_id' => $image->pressRelease?->user_id, 'channel' => ConfirmationChannel::Form, 'legal_text_id' => $text->id, 'legal_text_key' => $text->key, 'text_snapshot' => $text->body, 'agb_version' => $text->bound_agb_version, 'locale' => $text->locale, 'file_sha256' => null, 'declaration_snapshot' => [ 'copyright' => $image->copyright, 'author' => $image->author, 'license_type' => $image->license_type?->value, 'license_detail' => $image->license_detail, 'license_url' => $image->license_url, 'source_url' => $image->source_url, 'ai_declaration' => $image->ai_declaration?->value, 'backfilled' => true, ], 'confirmed_at' => $image->rights_confirmed_at, 'created_at' => now(), ]); $written++; } }); $this->info("Protokolleinträge angelegt: {$written}"); return self::SUCCESS; } }