fix(cms): allow archiving already-imported article documents
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Models\Document;
|
||||
use App\Models\DocumentCategory;
|
||||
use App\Models\DocumentVersion;
|
||||
use App\Models\User;
|
||||
use App\Services\SiteRevalidationService;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
@@ -127,6 +128,18 @@ class ImportArticleDocuments extends Command
|
||||
$existing = Document::where('public_uuid', $publicUuid)->first();
|
||||
|
||||
if ($existing) {
|
||||
if ($markArchived && $article->status !== Article::STATUS_ARCHIVED) {
|
||||
$article->update([
|
||||
'status' => Article::STATUS_ARCHIVED,
|
||||
'archived_at' => now(),
|
||||
'last_updated_by_user_id' => ($article->creator ?: $fallbackUser)->id,
|
||||
]);
|
||||
SiteRevalidationService::revalidateArticle($article->slug);
|
||||
$this->info("✓ {$article->slug}: already imported, source article archived.");
|
||||
|
||||
return 'archived_source';
|
||||
}
|
||||
|
||||
$this->warn("↷ {$article->slug}: already imported as document #{$existing->id}, skipping.");
|
||||
|
||||
return 'skipped';
|
||||
@@ -225,6 +238,7 @@ class ImportArticleDocuments extends Command
|
||||
'archived_at' => now(),
|
||||
'last_updated_by_user_id' => $actor->id,
|
||||
]);
|
||||
SiteRevalidationService::revalidateArticle($article->slug);
|
||||
}
|
||||
|
||||
AuditLog::create([
|
||||
|
||||
Reference in New Issue
Block a user