Make sure query filter works with database prefix

Related to flarum/core#269.
This commit is contained in:
Franz Liedke 2015-08-29 23:07:21 +02:00
parent 26e6993a49
commit 74fdf7b79c

View File

@ -2,6 +2,7 @@
use Flarum\Core\Search\Search;
use Flarum\Core\Search\RegexGambit;
use Illuminate\Database\Query\Expression;
class SubscriptionGambit extends RegexGambit
{
@ -16,7 +17,7 @@ class SubscriptionGambit extends RegexGambit
$search->getQuery()->$method(function ($query) use ($actor, $matches) {
$query->select(app('flarum.db')->raw(1))
->from('users_discussions')
->whereRaw('discussion_id = discussions.id')
->where('discussions.id', new Expression('discussion_id'))
->where('user_id', $actor->id)
->where('subscription', $matches[1] === 'follow' ? 'follow' : 'ignore');
});