Parcourir la source

Patients search - same criteria as in patients list

Vijayakrishnan il y a 4 ans
Parent
commit
736efd11ea
1 fichiers modifiés avec 2 ajouts et 27 suppressions
  1. 2 27
      app/Models/Pro.php

+ 2 - 27
app/Models/Pro.php

@@ -260,36 +260,11 @@ class Pro extends Model
 
     }
 
-    public function getMyClientIds(){
-
-        $accessibleClientIds = [];
-
-        $clientProAccesses = ClientProAccess::where('pro_id', $this->id)->get();
-        foreach($clientProAccesses as $cpa){
-            $accessibleClientIds[] = $cpa->client_id;
-        }
-
-        $appointmentClientIds = [];
-
-        $appointments = Appointment::where('pro_id', $this->id)->get();
-        foreach($appointments as $appts){
-            $appointmentClientIds[] = $appts->client_id;
-        }
-
-        $clients = Client::where('mcp_pro_id', $this->id)
-            ->orWhere('cm_pro_id', $this->id)
-            ->orWhere('rmm_pro_id', $this->id)
-            ->orWhere('rme_pro_id', $this->id)
-            ->orWhere('rd_pro_id', $this->id)
-            ->orWhereIn('id', $accessibleClientIds)
-            ->orWhereIn('id', $appointmentClientIds)->get();
-
-        $clientIds = [];
-
+    public function getMyClientIds() {
+        $clients = $this->getAccessibleClientsQuery()->get();
         foreach($clients as $client){
             $clientIds[] = $client->id;
         }
-
         return $clientIds;
     }