Skip to content

Commit

Permalink
更新:优化搜索结果
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuchunshu committed Jun 12, 2023
1 parent 6cf9277 commit fcfc20e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/Plugins/Search/src/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function index()
'url' => '/' . $item->id . '.html',
];
}
$topics2= [];
$topics2 = [];

$_topic = Post::where('topic_id', '!=', 'null')
->where('topic_id', '!=', '0')
Expand All @@ -58,7 +58,7 @@ public function index()
->get(['user_id', 'topic_id', 'content', 'created_at', 'id']);

foreach ($_topic as $topic) {
if (in_array($item, $topics2) || !Topic::where('id',$topic->topic_id)->exists()) {
if (in_array($item, $topics2) || ! Topic::where('id', $topic->topic_id)->exists()) {
continue;
}
$item = [
Expand All @@ -71,7 +71,7 @@ public function index()
'url' => '/tags' . $topic->topic->tag->id . '.html',
],
'created_at' => $topic->created_at,
'title' => @$topic->topic->title?:'暂无标题',
'title' => @$topic->topic->title ?: '暂无标题',
'content' => @str_limit(remove_bbCode(strip_tags($topic->content) ?: '暂无内容') ?: '暂无内容', 100),
'url' => '/' . $topic->topic_id . '.html',
];
Expand All @@ -80,7 +80,7 @@ public function index()
}

$data = array_merge($topics, $topics2);

$data = array_unique($data);
$page = $this->page($data);
return view('Search::data', ['page' => $page, 'q' => $q]);
}
Expand Down

0 comments on commit fcfc20e

Please sign in to comment.