Example #1
0
 /**
  * Find posts that match certain conditions, optionally making sure they
  * are visible to a certain user, and/or using other criteria.
  *
  * @param array $where
  * @param \Flarum\Core\Users\User|null $actor
  * @param array $sort
  * @param integer $count
  * @param integer $start
  * @return \Illuminate\Database\Eloquent\Collection
  */
 public function findWhere($where = [], User $actor = null, $sort = [], $count = null, $start = 0)
 {
     $query = Post::where($where)->skip($start)->take($count);
     foreach ((array) $sort as $field => $order) {
         $query->orderBy($field, $order);
     }
     $ids = $query->lists('id')->all();
     return $this->findByIds($ids, $actor);
 }
 /**
  * {@inheritdoc}
  */
 public function match($string)
 {
     $discussionIds = Post::where('type', 'comment')->where('content', 'like', "%{$string}%")->lists('discussion_id', 'id');
     $relevantPostIds = [];
     foreach ($discussionIds as $postId => $discussionId) {
         $relevantPostIds[$discussionId][] = $postId;
     }
     return $relevantPostIds;
 }
 /**
  * {@inheritdoc}
  */
 public function match($string)
 {
     $discussionIds = Post::where('type', 'comment')->whereRaw('MATCH (`content`) AGAINST (? IN BOOLEAN MODE)', [$string])->orderByRaw('MATCH (`content`) AGAINST (?) DESC', [$string])->lists('discussion_id', 'id');
     $relevantPostIds = [];
     foreach ($discussionIds as $postId => $discussionId) {
         $relevantPostIds[$discussionId][] = $postId;
     }
     return $relevantPostIds;
 }