/** * Find posts by matching a string of words against their content, * optionally making sure they are visible to a certain user. * * @param string $string * @param \Flarum\Core\Models\User|null $user * @return \Illuminate\Database\Eloquent\Collection */ public function findByContent($string, User $user = null) { $query = Post::select('id', 'discussion_id')->where('content', 'like', '%' . $string . '%'); // ->whereRaw('MATCH (`content`) AGAINST (? IN BOOLEAN MODE)', [$string]) // ->orderByRaw('MATCH (`content`) AGAINST (?) DESC', [$string]) return $this->scopeVisibleForUser($query, $user)->get(); }