%PDF- %PDF-
Direktori : /var/www/html/klinisol/klinisol-api/app/Transformers/ |
Current File : /var/www/html/klinisol/klinisol-api/app/Transformers/PatientTransformer.php |
<?php namespace App\Transformers; use App\Models\Patient; class PatientTransformer extends BaseTransformer { protected $availableIncludes = [ 'hospital', 'protocols', ]; protected $defaultIncludes = []; public function includeHospital(Patient $patient) { if ($hospital = $patient->hospital()) { return $this->item($hospital, new HospitalTransformer(), 'hospital'); } return null; } /** * @param Patient $patient * @return \League\Fractal\Resource\Collection */ public function includeProtocols(Patient $patient) { return $this->collection($patient->protocols, new PatientProtocolTransformer(), 'protocols'); } public function transform(Patient $patient) { return [ 'id' => $patient->id, 'code' => $patient->code, 'name' => $patient->name, 'surname' => $patient->surname, 'fullName' => $patient->name . ' ' . $patient->surname, 'email' => $patient->email, 'phone' => $patient->phone, ]; } }