fix resources hospital
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace Modules\Linksehat\Transformers\Hospital;
|
||||
|
||||
use App\Models\PractitionerRole;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Modules\Linksehat\Transformers\Speciality\SpecialityForHospitalDetailResource;
|
||||
|
||||
class HospitalResource extends JsonResource
|
||||
{
|
||||
@@ -15,20 +15,6 @@ class HospitalResource extends JsonResource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$querySpecialitys = PractitionerRole::query()
|
||||
->with(['speciality'])
|
||||
->where('organization_id', $this->id)
|
||||
->whereNotNull('speciality_id')
|
||||
->orderBy('speciality_id')
|
||||
->groupBy('speciality_id')
|
||||
->get(['speciality_id']);
|
||||
|
||||
foreach ($querySpecialitys as $indexSpeciality => $speciality) {
|
||||
$specialitys[$indexSpeciality]['id'] = $speciality->speciality->id;
|
||||
$specialitys[$indexSpeciality]['name'] = $speciality->speciality->name;
|
||||
$specialitys[$indexSpeciality]['avatar'] = asset('images/default-specialisasi-image.png');
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
@@ -45,7 +31,10 @@ class HospitalResource extends JsonResource
|
||||
'photos' => [
|
||||
'title' => $this->name,
|
||||
'photo_url' => url('images/default-hospital-image.png'),
|
||||
]
|
||||
],
|
||||
$this->mergeWhen($this->specialities, [
|
||||
'specialities' => SpecialityForHospitalDetailResource::collection($this->specialities)
|
||||
])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user