Ver código fonte

timePeriodList

Mike 4 anos atrás
pai
commit
9e86f9c022
1 arquivos alterados com 1 adições e 18 exclusões
  1. 1 18
      app/Http/Controllers/Api/V1/DocterController.php

+ 1 - 18
app/Http/Controllers/Api/V1/DocterController.php

xqd
@@ -278,25 +278,8 @@ class DocterController extends AuthController
             'latitude' => 'numeric',
             'longitude' => 'numeric',
         ]);
-        $builder = Schedule::with(['schedulePeriod.timePeriod', 'schedulePeriod.organization'])->where('docter_id', $req['docter_id'])->where('schedule_type', $req['schedule_type'])->where('schedule_day', '>=', date('Ymd'));
-        if (!empty($req['organization_id'])) {
-            $builder->where('organization_id', $req['organization_id']);
-        }
+        $builder = SchedulePeriod::with(['timePeriod'])->where('organization_id', $req['organization_id'])->where('schedule_type',$req['schedule_type'])->where('', '>=', date('Ymd'))->orderBy('schedule_date');
         $data = $builder->paginate($req['per_page']??15)->toArray();
-        if (!empty($data)) {
-            foreach ($data['data'] as $k => &$v) {
-                foreach ($v['schedule_period'] as $k1 => &$v1) {
-                    $docterSettings = DocterSetting::select(['service_num'])->where('docter_id', $req['docter_id'])->where('type', 1)->where('org_id', $v1['organization_id'])->first();
-                    if (empty($docterSettings)) {
-                        $v1['can_appoint_num'] = 0;
-                    }
-                    else {
-                        $can_appoint_num = $docterSettings['service_num'] - $v1['order_num'];
-                        $v1['can_appoint_num'] = $can_appoint_num < 0 ? 0 : $can_appoint_num;
-                    }
-                }
-            }
-        }
 
         return out($data);
     }