浏览代码

Show distinct codes in <select>s

Vijayakrishnan Krishnan 4 年之前
父节点
当前提交
d09bf24677
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      app/Models/Pro.php

+ 6 - 3
app/Models/Pro.php

@@ -46,21 +46,24 @@ class Pro extends Model
     }
 
     public function cmRates() {
-        return ProRate::where('is_active', true)
+        return ProRate::distinct('code')
+            ->where('is_active', true)
             ->where('pro_id', $this->id)
             ->where('code', 'LIKE', 'CM%')
             ->get();
     }
 
     public function rmRates() {
-        return ProRate::where('is_active', true)
+        return ProRate::distinct('code')
+            ->where('is_active', true)
             ->where('pro_id', $this->id)
             ->where('code', 'LIKE', 'RM%')
             ->get();
     }
 
     public function noteRates() {
-        return ProRate::where('is_active', true)
+        return ProRate::distinct('code')
+            ->where('is_active', true)
             ->where('pro_id', $this->id)
             ->where('code', 'NOT LIKE', 'CM%')
             ->where('code', 'NOT LIKE', 'RM%')