瀏覽代碼

add scopeType

visuddhinanda 1 周之前
父節點
當前提交
353523b70b
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      api-v13/app/Models/Sentence.php

+ 7 - 0
api-v13/app/Models/Sentence.php

@@ -48,6 +48,13 @@ class Sentence extends Model
         return $this->belongsTo(Channel::class, 'channel_uid', 'uid');
         return $this->belongsTo(Channel::class, 'channel_uid', 'uid');
     }
     }
 
 
+    public function scopeType($query, $type)
+    {
+        return $query->whereHas('channel', function ($q) use ($type) {
+            $q->where('type', $type);
+        });
+    }
+
     public function scopeNissaya($query)
     public function scopeNissaya($query)
     {
     {
         return $query->whereHas('channel', function ($q) {
         return $query->whereHas('channel', function ($q) {