Found the source of the issue, not sure how to fix
This commit is contained in:
		
							parent
							
								
									5681f4dd69
								
							
						
					
					
						commit
						33bf20cfc8
					
				| 
						 | 
					@ -100,10 +100,14 @@ abstract class Entity extends Model
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static function fullTextSearchQuery($fieldsToSearch, $terms, $wheres = [])
 | 
					    public static function fullTextSearchQuery($fieldsToSearch, $terms, $wheres = [])
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $termString = '';
 | 
					        foreach ($terms as $key => $term) {
 | 
				
			||||||
        foreach ($terms as $term) {
 | 
					            $term = htmlentities($term);
 | 
				
			||||||
            $termString .= htmlentities($term) . '* ';
 | 
					            if (preg_match('/\s/', $term)) {
 | 
				
			||||||
 | 
					                $term = '"' . $term . '"';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            $terms[$key] = $term . '*';
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        $termString = "'" . implode(' ', $terms) . "'";
 | 
				
			||||||
        $fields = implode(',', $fieldsToSearch);
 | 
					        $fields = implode(',', $fieldsToSearch);
 | 
				
			||||||
        $termStringEscaped = \DB::connection()->getPdo()->quote($termString);
 | 
					        $termStringEscaped = \DB::connection()->getPdo()->quote($termString);
 | 
				
			||||||
        $search = static::addSelect(\DB::raw('*, MATCH(name) AGAINST('.$termStringEscaped.' IN BOOLEAN MODE) AS title_relevance'));
 | 
					        $search = static::addSelect(\DB::raw('*, MATCH(name) AGAINST('.$termStringEscaped.' IN BOOLEAN MODE) AS title_relevance'));
 | 
				
			||||||
| 
						 | 
					@ -113,9 +117,8 @@ abstract class Entity extends Model
 | 
				
			||||||
        foreach ($wheres as $whereTerm) {
 | 
					        foreach ($wheres as $whereTerm) {
 | 
				
			||||||
            $search->where($whereTerm[0], $whereTerm[1], $whereTerm[2]);
 | 
					            $search->where($whereTerm[0], $whereTerm[1], $whereTerm[2]);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Load in relations
 | 
					        // Load in relations
 | 
				
			||||||
        if (static::isA('page'))  {
 | 
					        if (static::isA('page')) {
 | 
				
			||||||
            $search = $search->with('book', 'chapter', 'createdBy', 'updatedBy');
 | 
					            $search = $search->with('book', 'chapter', 'createdBy', 'updatedBy');
 | 
				
			||||||
        } else if (static::isA('chapter')) {
 | 
					        } else if (static::isA('chapter')) {
 | 
				
			||||||
            $search = $search->with('book');
 | 
					            $search = $search->with('book');
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -208,7 +208,9 @@ class PageRepo
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $terms = [];
 | 
					            $terms = [];
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        $terms = array_merge($terms, explode(' ', $term));
 | 
					        if (!empty($term)) {
 | 
				
			||||||
 | 
					            $terms = array_merge($terms, explode(' ', $term));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        $pages = $this->page->fullTextSearchQuery(['name', 'text'], $terms, $whereTerms)
 | 
					        $pages = $this->page->fullTextSearchQuery(['name', 'text'], $terms, $whereTerms)
 | 
				
			||||||
            ->paginate($count)->appends($paginationAppends);
 | 
					            ->paginate($count)->appends($paginationAppends);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue