37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Admin;
|
|
|
|
use App\Enums\DocumentStatusEnum;
|
|
use App\Enums\DocumentPriorityEnum;
|
|
use Hekmatinasser\Verta\Verta;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class DocumentResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'note' => $this->note,
|
|
'priority' => $this->priority,
|
|
'image' => $this->image,
|
|
'code' => $this->code,
|
|
'modality' => $this->modality,
|
|
'status' => $this->status,
|
|
'priority' => $this->priority,
|
|
'pet' => $this->relationLoaded('pet') ? optional($this->pet)->only(['id','name','birthday']) : null,
|
|
'requester' => $this->relationLoaded('requester') ? optional($this->requester)->only(['id','fullname']) : null,
|
|
'submitted_at' => verta($this->submitted_at)->format('%Y/%m/%d - H:i'),
|
|
'processing_deadline' => verta($this->processing_deadline)->format('%Y/%m/%d - H:i'),
|
|
];
|
|
|
|
}
|
|
}
|