Commit 3afc4b97 authored by Alfonso Rafael Solis Rangel's avatar Alfonso Rafael Solis Rangel
Browse files

Nueva logica para obtener subgrupos

parent e411f711
Loading
Loading
Loading
Loading
+22 −17
Original line number Diff line number Diff line
@@ -71,14 +71,18 @@ public function headings(): array

    private function applyFilters($query)
    {

        if(count($this->filters['subgrupos']) > 2){
            $query->orWhereHas('subgrupos', function ($q) {
                $q->whereIn('subgrupos.id', $this->filters['subgrupos']);
            });
        }else{
            if (!empty($this->filters['subgrupos'])) {
                $query->orWhereHas('subgrupos', function ($q) {
                    $q->whereIn('subgrupos.id', $this->filters['subgrupos']);
                });
            } elseif (!empty($this->filters['grupos'])) {
                $grupoId = $this->filters['grupos'];
            $subgruposIds = Grupos::find(153)->subgrupos->pluck('id')->toArray();
                $subgruposIds = Grupos::find($grupoId)->subgrupos->pluck('id')->toArray();
        
                $query->where(function ($query) use ($grupoId, $subgruposIds) {
                    // Contactos directamente en el grupo
@@ -94,6 +98,7 @@ private function applyFilters($query)
                    }
                });
            }
        }

        if ($this->filters['mesInicio'] != "NaN" && $this->filters['diaInicio'] != "NaN") {
            $mesInicio = $this->filters['mesInicio'];