Update gambit for search API

This commit is contained in:
Toby Zerner 2015-06-26 12:22:08 +09:30
parent e41e50f423
commit 8ba856df79

View File

@ -36,13 +36,14 @@ class TagGambit extends GambitAbstract
* @param \Flarum\Core\Search\SearcherInterface $searcher * @param \Flarum\Core\Search\SearcherInterface $searcher
* @return void * @return void
*/ */
public function conditions($matches, SearcherInterface $searcher) protected function conditions(SearcherInterface $searcher, array $matches, $negate)
{ {
$slugs = explode(',', trim($matches[1], '"')); $slugs = explode(',', trim($matches[1], '"'));
$searcher->query()->where(function ($query) use ($slugs) { // TODO: implement $negate
$searcher->getQuery()->where(function ($query) use ($slugs) {
foreach ($slugs as $slug) { foreach ($slugs as $slug) {
if ($slug === 'uncategorized') { if ($slug === 'untagged') {
$query->orWhereNotExists(function ($query) { $query->orWhereNotExists(function ($query) {
$query->select(app('db')->raw(1)) $query->select(app('db')->raw(1))
->from('discussions_tags') ->from('discussions_tags')