1
0
mirror of https://github.com/flarum/core.git synced 2025-08-14 20:34:10 +02:00

Add Mentions section to user profile (fixes flarum/core#319)

This commit is contained in:
Sajjad Hasehmian
2016-02-04 01:04:08 +03:30
parent b35fa5a556
commit b4d7c18eb9
5 changed files with 148 additions and 2 deletions

View File

@@ -0,0 +1,36 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Mentions\Listener;
use Flarum\Event\ConfigurePostsQuery;
use Illuminate\Contracts\Events\Dispatcher;
class AddFilterByMentions
{
/**
* @param Dispatcher $events
*/
public function subscribe(Dispatcher $events)
{
$events->listen(ConfigurePostsQuery::class, [$this, 'addFilter']);
}
/**
* @param ConfigurePostsQuery $event
*/
public function addFilter(ConfigurePostsQuery $event)
{
if ($mentionedId = array_get($event->filter, 'mentioned')) {
$event->query->join('mentions_users', 'posts.id', '=', 'mentions_users.post_id')
->where('mentions_users.mentions_id', '=', $mentionedId);
}
}
}