Prechádzať zdrojové kódy

Devices - include devices that are assigned but is_active is false

Vijayakrishnan 4 rokov pred
rodič
commit
c19e544a7a

+ 8 - 2
app/Http/Controllers/PatientController.php

@@ -26,7 +26,10 @@ class PatientController extends Controller
         $facilities = []; // Facility::where('is_active', true)->get();
         $devices = BDTDevice::where('is_active', true)->orderBy('imei', 'asc')->get();
         $devices = $devices->filter(function ($record) {
-            $matching = ClientBDTDevice::where('device_id', $record->id)->get();
+            $matching = ClientBDTDevice
+                ::where('device_id', $record->id)
+                ->where('is_active', true)
+                ->get();
             return count($matching) === 0;
         });
         $dxInfoLines = ClientInfoLine::where('client_id', $patient->id)
@@ -153,7 +156,10 @@ class PatientController extends Controller
     {
         $devices = BDTDevice::where('is_active', true)->get();
         $devices = $devices->filter(function ($record) {
-            $matching = ClientBDTDevice::where('device_id', $record->id)->get();
+            $matching = ClientBDTDevice
+                ::where('device_id', $record->id)
+                ->where('is_active', true)
+                ->get();
             return count($matching) === 0;
         });
         return view('app.patient.devices', compact('patient', 'devices'));