Files
aso/Modules/Linksehat/Transformers/Person/PersonResource.php
2022-11-02 11:45:01 +07:00

38 lines
1.2 KiB
PHP

<?php
namespace Modules\Linksehat\Transformers\Person;
use App\Helpers\Helper;
use Illuminate\Http\Resources\Json\JsonResource;
class PersonResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'birth_place' => $this->birth_place,
'gender' => $this->gender,
'phone' => $this->phone,
'email' => $this->email,
'blood_type' => $this->blood_type,
'weight' => $this->weight,
'height' => $this->height,
'relation_with_owner' => ($this->user && $this->user->person_id == $this->id) ? 'Self' : $this->pivot->relation_with_owner ?? null,
'marital_status' => $this->marital_status,
'last_education' => $this->last_education,
'current_employment' => $this->current_employment,
'nik' => $this->nik,
'religion' => $this->religion,
'avatar_url' => $this->avatar->url ?? asset('images/default-doctor-avatar.png'),
];
}
}