Update (fix) search

This commit is contained in:
2023-11-20 11:29:52 +08:00
parent d17185641c
commit 7166eb610c
2 changed files with 8 additions and 7 deletions

View File

@@ -56,7 +56,7 @@ public function render($request, Throwable $exception)
} elseif ($exception instanceof AuthenticationException) {
} else {
inspector()->reportException($exception);
//inspector()->reportException($exception);
}
//default laravel response

View File

@@ -34,12 +34,13 @@ public function search(Request $request)
// Use full-text search capabilities of your database
// For example, using MySQL's full-text search with MATCH...AGAINST
$posts = Post::with('category')
->where('status', 'publish')
->whereRaw("to_tsvector('english', title || ' ' || bites) @@ to_tsquery('english', ?)", [$query])
->where('published_at', '<=', now())
->orderBy('published_at', 'desc')
->cursorPaginate(10);
$posts = Post::with('category')
->where('status', 'publish')
->whereRaw("to_tsvector('english', title || ' ' || bites) @@ to_tsquery('english', ?)", [str_replace(' ', ' & ', $query)])
->where('published_at', '<=', now())
->orderBy('published_at', 'desc')
->cursorPaginate(10);
// breadcrumb json ld
$listItems = [];