41 lines
1.5 KiB
PHP
41 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class PersonResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'person_id' => $this->person_id,
|
|
'surname' => $this->surname,
|
|
'christian_name' => $this->christian_name,
|
|
'full_name' => $this->full_name,
|
|
'date_of_birth' => $this->date_of_birth,
|
|
'place_of_birth' => $this->place_of_birth,
|
|
'date_of_death' => $this->date_of_death,
|
|
'occupation' => $this->occupation,
|
|
'additional_notes' => $this->additional_notes,
|
|
'reference' => $this->reference,
|
|
'id_card_no' => $this->id_card_no,
|
|
'created_at' => $this->created_at,
|
|
'updated_at' => $this->updated_at,
|
|
|
|
// Include related resources when they're loaded
|
|
'migration' => new MigrationResource($this->whenLoaded('migration')),
|
|
'naturalization' => new NaturalizationResource($this->whenLoaded('naturalization')),
|
|
'residence' => new ResidenceResource($this->whenLoaded('residence')),
|
|
'family' => new FamilyResource($this->whenLoaded('family')),
|
|
'internment' => new InternmentResource($this->whenLoaded('internment')),
|
|
];
|
|
}
|
|
}
|