/** * Get notifications. * * @param bool|int $limit * @return mixed */ public static function get($limit = false) { $notifications = Notification::select('notifications.id', 'notification_types.type', 'notifications.title', 'notifications.message', 'notifications.created_at', 'notifications.updated_at', 'targeted_users.key', 'targeted_users.name as target_group')->leftJoin('notification_types', 'notifications.notification_type_id', '=', 'notification_types.id')->leftJoin('targeted_users', 'notifications.targeted_user_id', '=', 'targeted_users.id')->groupBy('notifications.id')->orderBy('notifications.created_at', 'desc'); if ($limit) { $notifications->limit($limit); } return $notifications->get(); }