38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?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,
|
|
'lang' => $document->lang->value,
|
|
'published' => ($document->status) ? 1 : 0,
|
|
'parent' => $document->document_id,
|
|
'created_at' => $document->created_at,
|
|
'updated_at' => $document->updated_at,
|
|
];
|
|
}
|
|
}
|