zilong 4 سال پیش
والد
کامیت
1ab3812e1a
1فایلهای تغییر یافته به همراه5 افزوده شده و 2 حذف شده
  1. 5 2
      app/Http/Controllers/Api/V1/DocterController.php

+ 5 - 2
app/Http/Controllers/Api/V1/DocterController.php

xqd
@@ -165,8 +165,11 @@ class DocterController extends AuthController
 
         $data = Docter::with(['office', 'qualification', 'evaluate.user'])->select(['id', 'type', 'name', 'phone', 'sex', 'birthday', 'avatar', 'status', 'label', 'sign', 'intro', 'office_id', 'qualification_id', 'score', 'service_persons', 'eva_num', 'service_days', 'phone_minutes', 'chat_price', 'phone_price', 'appoint_price', 'is_chat', 'is_phone', 'is_appoint', 'latitude', 'longitude', DB::raw($distance_field)])->where('id', $req['docter_id'])->where('status', 1)->first()->toArray();
 
-        $schedulePeriod = SchedulePeriod::with('organization')->select(['organization_id'])->where('docter_id', $req['docter_id'])->get()->toArray();
-        $data['organization'] = array_column($schedulePeriod, 'organization');
+        $organization_ids = SchedulePeriod::where('docter_id', $req['docter_id'])->groupBy('organization_id')->pluck('organization_id')->toArray();
+        $data['organization'] = [];
+        if (!empty($organization_ids)) {
+            $data['organization'] = Organization::whereIn('id', $organization_ids)->get()->toArray();
+        }
 
         return ($data);
     }