Преглед на файлове

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