1
0
mirror of https://github.com/flarum/core.git synced 2025-10-27 05:31:29 +01:00

Rework notifications architecture

- The recipient(s) are the concern of the notifier/sender, not the
notification itself
- Allow “retraction” of notifications (e.g. if a discussion is
stickied, but then it is unstickied)
- Misc. cleanup
This commit is contained in:
Toby Zerner
2015-05-14 22:39:57 +09:30
parent 6517b1ec3e
commit 3925e5892c
11 changed files with 73 additions and 78 deletions

View File

@@ -5,15 +5,15 @@ use DB;
class EloquentNotificationRepository implements NotificationRepositoryInterface
{
public function findByUser($userId, $count = null, $start = 0)
public function findByUser($userId, $limit = null, $offset = 0)
{
$primaries = Notification::select(DB::raw('MAX(id) AS id'), DB::raw('SUM(is_read = 0) AS unread_count'))
->where('user_id', $userId)
->whereIn('type', array_keys(Notification::getTypes()))
->groupBy('type', 'subject_id')
->orderBy('time', 'desc')
->skip($start)
->take($count);
->skip($offset)
->take($limit);
return Notification::with('subject')
->select('notifications.*', 'p.unread_count')