zilong 4 년 전
부모
커밋
caa28f99d0
1개의 변경된 파일18개의 추가작업 그리고 0개의 파일을 삭제
  1. 18 0
      app/Models/SchedulePeriod.php

+ 18 - 0
app/Models/SchedulePeriod.php

xqd
@@ -24,4 +24,22 @@ class SchedulePeriod extends BaseModel
     {
         return $this->hasOne(Docter::class,'id','docter_id');
     }
+
+    public function getOrderNumAttribute()
+    {
+        $map = [1 => 3, 2 => 4, 3 => 5];
+        $builder = Order::where('product_type', $map[$this->schedule_type]);
+        if ($this->schedule_type == 1) {
+            $builder->where('docter_id', $this->docter_id);
+        }
+        else {
+            $builder->where('organization_id', $this->organization_id);
+        }
+
+        $timePeriod = TimePeriod::select(['start_time_period'])->where('id', $this->time_period_id)->first();
+        $appoint_start_time = strtotime($this->schedule_date.' '.$timePeriod['start_time_period'].':00');
+        $count = $builder->where('appoint_start_time', $appoint_start_time)->count();
+
+        return $count;
+    }
 }