ldc-com-app-bo/app/Http/Resources/DocumentResource.php

39 lines
1.2 KiB
PHP
Raw Permalink Normal View History

<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class DocumentResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
*/
public function toArray($request)
{
/**
* @var \App\Models\Document
* @phpstan-ignore varTag.nativeType
*/
$document = $this;
return [
'id' => $document->id,
'uuid' => $document->uuid,
'title' => $document->title,
'type' => $document->type,
'directory' => $document->directory_id,
'path' => $document->path,
2025-06-12 15:47:26 +02:00
'lang' => $document->lang->name,
'published' => ($document->status) ? 1 : 0,
'parent' => $document->document_id,
'created_at' => $document->created_at,
'updated_at' => $document->updated_at,
];
}
}