32 lines
1.1 KiB
PHP
32 lines
1.1 KiB
PHP
<?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,
|
|
]),
|
|
];
|
|
}
|
|
}
|