zilong 4 rokov pred
rodič
commit
25cee82d4a
1 zmenil súbory, kde vykonal 25 pridanie a 1 odobranie
  1. 25 1
      app/Models/Docter.php

+ 25 - 1
app/Models/Docter.php

xqd xqd
@@ -13,7 +13,7 @@ class Docter extends BaseModel
     protected $casts = [
         'label' => 'json',
     ];
-    protected $appends = ['is_collect', 'label_texts'];
+    protected $appends = ['is_collect', 'label_texts', 'is_can_phone', 'is_can_chat'];
 
     public function office()
     {
@@ -95,4 +95,28 @@ class Docter extends BaseModel
         $base_price = DocterTimes::where('docter_id', $this->id)->where('type', 1)->value('base_price');
         return $base_price*100;
     }
+
+    public function getIsCanPhoneAttribute()
+    {
+        if ($this->is_phone == 1) {
+            $now_line = (int)date('Hi');
+            if (DocterServiceTime::where('docter_id', $this->id)->where('type', 1)->where('start_time_line', '<=', $now_line)->where('end_time_line', '>', $now_line)->exists()) {
+                return 1;
+            }
+        }
+
+        return 0;
+    }
+
+    public function getIsCanChatAttribute()
+    {
+        if ($this->is_chat == 1) {
+            $now_line = (int)date('Hi');
+            if (DocterServiceTime::where('docter_id', $this->id)->where('type', 2)->where('start_time_line', '<=', $now_line)->where('end_time_line', '>', $now_line)->exists()) {
+                return 1;
+            }
+        }
+
+        return 0;
+    }
 }