37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Employee;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class PractitionerDocumentResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray($request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'practitioner_id' => $this->practitioner_id,
|
|
'doc_type' => $this->doc_type,
|
|
'file_id' => $this->file_id,
|
|
'issue_date' => $this->issue_date?->format('Y-m-d'),
|
|
'expiry_date' => $this->expiry_date?->format('Y-m-d'),
|
|
'status' => $this->status,
|
|
'is_valid' => $this->is_valid,
|
|
'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
|
|
'updated_at' => $this->updated_at?->format('Y-m-d H:i:s'),
|
|
|
|
// Relations
|
|
'thanatopractitioner' => $this->when(
|
|
$this->relationLoaded('thanatopractitioner'),
|
|
new ThanatopractitionerResource($this->thanatopractitioner)
|
|
),
|
|
];
|
|
}
|
|
}
|