Przeglądaj źródła

Show distinct codes in <select>s

Vijayakrishnan Krishnan 4 lat temu
rodzic
commit
d09bf24677
1 zmienionych plików z 6 dodań i 3 usunięć
  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%')