- preg_match_all('/"(.*?)"/', $term, $matches);
- if (count($matches[1]) > 0) {
- $terms = $matches[1];
- $term = trim(preg_replace('/"(.*?)"/', '', $term));
- } else {
- $terms = [];
- }
- $terms = array_merge($terms, explode(' ', $term));
- $chapters = $this->chapter->fullTextSearchQuery(['name', 'description'], $terms, $whereTerms)
- ->paginate($count)->appends($paginationAppends);
+ $terms = $this->prepareSearchTerms($term);
+ $chapterQuery = $this->permissionService->enforceChapterRestrictions($this->chapter->fullTextSearchQuery(['name', 'description'], $terms, $whereTerms));
+ $chapterQuery = $this->addAdvancedSearchQueries($chapterQuery, $term);
+ $chapters = $chapterQuery->paginate($count)->appends($paginationAppends);