소스 검색

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%')