BookStack\Repos\BookRepo::getBySearch PHP Method

getBySearch() public method

Get books by search term.
public getBySearch ( $term, integer $count = 20, array $paginationAppends = [] ) : mixed
$term
$count integer
$paginationAppends array
return mixed
    public function getBySearch($term, $count = 20, $paginationAppends = [])
    {
        $terms = $this->prepareSearchTerms($term);
        $bookQuery = $this->permissionService->enforceBookRestrictions($this->book->fullTextSearchQuery(['name', 'description'], $terms));
        $bookQuery = $this->addAdvancedSearchQueries($bookQuery, $term);
        $books = $bookQuery->paginate($count)->appends($paginationAppends);
        $words = join('|', explode(' ', preg_quote(trim($term), '/')));
        foreach ($books as $book) {
            //highlight
            $result = preg_replace('#' . $words . '#iu', "<span class=\"highlight\">\$0</span>", $book->getExcerpt(100));
            $book->searchSnippet = $result;
        }
        return $books;
    }