public function getNotifications(User $user) { $results = DB::select("\n SELECT\n *,\n COUNT(*) AS groupCount,\n GROUP_CONCAT(DISTINCT fromUserId SEPARATOR ',') AS fromUserIds\n FROM\n notifications\n WHERE\n userId = ?\n AND\n seenAt IS NULL\n GROUP BY\n " . implode(',', $this->groupFields) . "\n ORDER BY\n id DESC\n ", [$user->id]); $notifications = Notification::hydrate($results); return $notifications; }