/** * Use first criteria to get a list of all possible groups for the search. * This will be further reduced by other criteria elsewhere. * @return mixed */ private function getSuperset() { // Pull the first category $cat = array_shift($this->categories); // Get the tags for the category choices $tags = $this->getTagList($cat); // Save the full list of groups $this->allGroups = Group::whereHas('tags', function ($q) use($tags) { $q->whereIn('tag_id', $tags); })->with(['tags' => function ($q) { $q->select('tags.id', 'tags.name'); }])->get()->toArray(); }