mirror of
https://github.com/flarum/core.git
synced 2025-08-13 11:54:32 +02:00
Compare commits
10 Commits
dk/likes/l
...
dk/2022032
Author | SHA1 | Date | |
---|---|---|---|
|
88b5918e3a | ||
|
d0119e7634 | ||
|
726c8f3a9a | ||
|
8fe1d1cabc | ||
|
d0b4e74b1f | ||
|
65c861ab7b | ||
|
cb9fe6930f | ||
|
3343fde5f2 | ||
|
907b1f10aa | ||
|
ae7d31ec16 |
@@ -55,23 +55,23 @@ class TagFilterGambit extends AbstractRegexGambit implements FilterInterface
|
|||||||
{
|
{
|
||||||
$slugs = explode(',', trim($rawSlugs, '"'));
|
$slugs = explode(',', trim($rawSlugs, '"'));
|
||||||
|
|
||||||
$query->where(function (Builder $query) use ($slugs, $negate) {
|
$query
|
||||||
foreach ($slugs as $slug) {
|
->distinct()
|
||||||
if ($slug === 'untagged') {
|
->leftJoin('discussion_tag', 'discussions.id', '=', 'discussion_tag.discussion_id')
|
||||||
$query->whereIn('discussions.id', function (Builder $query) {
|
->where(function (Builder $query) use ($slugs, $negate) {
|
||||||
$query->select('discussion_id')
|
foreach ($slugs as $slug) {
|
||||||
->from('discussion_tag');
|
if ($slug === 'untagged' && ! $negate) {
|
||||||
}, 'or', ! $negate);
|
$query->orWhereNull('discussion_tag.tag_id');
|
||||||
} else {
|
} elseif ($slug === 'untagged' && $negate) {
|
||||||
$id = $this->tags->getIdForSlug($slug);
|
$query->orWhereNotNull('discussion_tag.tag_id');
|
||||||
|
} elseif ($id = $this->tags->getIdForSlug($slug)) {
|
||||||
$query->whereIn('discussions.id', function (Builder $query) use ($id) {
|
$query->orWhere(
|
||||||
$query->select('discussion_id')
|
'discussion_tag.tag_id',
|
||||||
->from('discussion_tag')
|
$negate ? '!=' : '=',
|
||||||
->where('tag_id', $id);
|
$id
|
||||||
}, 'or', $negate);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,9 @@ use Flarum\Foundation\EventGeneratorTrait;
|
|||||||
use Flarum\Notification\Notification;
|
use Flarum\Notification\Notification;
|
||||||
use Flarum\Post\Event\Deleted;
|
use Flarum\Post\Event\Deleted;
|
||||||
use Flarum\User\User;
|
use Flarum\User\User;
|
||||||
|
use Illuminate\Database\ConnectionInterface;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Query\Expression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $id
|
* @property int $id
|
||||||
@@ -91,7 +93,19 @@ class Post extends AbstractModel
|
|||||||
// discussion.
|
// discussion.
|
||||||
static::creating(function (self $post) {
|
static::creating(function (self $post) {
|
||||||
$post->type = $post::$type;
|
$post->type = $post::$type;
|
||||||
$post->number = ++$post->discussion->post_number_index;
|
|
||||||
|
/** @var ConnectionInterface $db */
|
||||||
|
$db = static::getConnectionResolver();
|
||||||
|
$post->number = new Expression('('.$db
|
||||||
|
->table('posts', 'pn')
|
||||||
|
->whereRaw($db->getTablePrefix().'pn.discussion_id = '.intval($post->discussion_id))
|
||||||
|
->select($db->raw('max('.$db->getTablePrefix().'pn.number) + 1'))
|
||||||
|
->toSql()
|
||||||
|
.')');
|
||||||
|
});
|
||||||
|
|
||||||
|
static::created(function (self $post) {
|
||||||
|
$post->refresh();
|
||||||
$post->discussion->save();
|
$post->discussion->save();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user