Files
kartoteka/app/Http/Resources/SI/SttMedicalHistoryResource.php
2025-12-19 00:35:42 +09:00

32 lines
1.0 KiB
PHP

<?php
namespace App\Http\Resources\SI;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Carbon;
class SttMedicalHistoryResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'fullname' => $this->getFullNameAttribute(),
'daterecipient' => Carbon::parse($this->daterecipient)->format('d.m.Y'),
'dateextract' => Carbon::parse($this->dateextract)->format('d.m.Y'),
'card_num' => $this->archiveInfo->num ?? null,
'status' => $this->archiveInfo->status ?? null,
'datearhiv' => $this->whenLoaded('archiveInfo') ? Carbon::parse($this->archiveInfo->post_in)->format('d.m.Y') : null,
'medcardnum' => $this->medcardnum,
'dr' => Carbon::parse($this->dr)->format('d.m.Y'),
'can_be_issue' => $this->canBeIssued()
];
}
}