jjandxa
可以搜索标题的版本
把 use Flarum\Core\Post;
这行改成:
use Flarum\Core\Post;
use Flarum\Core\Discussion;
把下面的match函数部分改成:
public function match($string)
{
$discussionTitleIds = Discussion::where('title', 'like', "%$string%")
->lists('id');
$discussionIds = Post::where('type', 'comment')
->where('content', 'like', "%$string%")
->lists('discussion_id', 'id');
$relevantPostIds = [];
foreach ($discussionTitleIds as $discussionId) {
$relevantPostIds[$discussionId][] = 0;
}
foreach ($discussionIds as $postId => $discussionId) {
$relevantPostIds[$discussionId][] = $postId;
}
return $relevantPostIds;
}