feat(cms): expose public document api and trigger site revalidation

This commit is contained in:
2026-02-11 09:00:11 +08:00
parent b6e18a83ec
commit 4e7ef92d0b
10 changed files with 489 additions and 50 deletions

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class PublicDocumentVersionResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'version_number' => $this->version_number,
'version_notes' => $this->version_notes,
'is_current' => (bool) $this->is_current,
'original_filename' => $this->original_filename,
'mime_type' => $this->mime_type,
'file_extension' => $this->getFileExtension(),
'file_size' => $this->file_size,
'file_size_human' => $this->getFileSizeHuman(),
'file_hash' => $this->file_hash,
'uploaded_by' => $this->uploadedBy?->name,
'uploaded_at' => $this->uploaded_at?->toIso8601String(),
'download_url' => route('documents.public.download-version', [
'uuid' => $this->document->public_uuid,
'version' => $this->id,
]),
];
}
}