PHPackages                             musonza/groups - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. musonza/groups

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

musonza/groups
==============

Laravel 5 user groups package

v1.3.0(6y ago)693.1k16[5 issues](https://github.com/musonza/groups/issues)MITPHPCI failing

Since Apr 2Pushed 6y ago9 watchersCompare

[ Source](https://github.com/musonza/groups)[ Packagist](https://packagist.org/packages/musonza/groups)[ RSS](/packages/musonza-groups/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (5)Versions (10)Used By (0)

[![Build Status](https://camo.githubusercontent.com/82087ad8888d06b50b47da3924c8585ea2317c015570a02bf64b6f961d38ccc1/68747470733a2f2f7472617669732d63692e6f72672f6d75736f6e7a612f67726f7570732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/musonza/groups)[![Downloads](https://camo.githubusercontent.com/e241c657b4a0dddc48ff780a668002b39bd61e694e9ac609739fc8aa89165e28/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d75736f6e7a612f67726f7570732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/musonza/groups)[![Packagist](https://camo.githubusercontent.com/2c0028103c2ccc91ff6264bd3928136c3b258e2b39ae1be93424a6393e05299d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d75736f6e7a612f67726f7570732e737667)](https://packagist.org/packages/musonza/groups)[![StyleCI](https://camo.githubusercontent.com/fdd645b7655dfd8cd901650922d6e5bababb41f199670e2c75d914ba5cd0d2af/68747470733a2f2f7374796c6563692e696f2f7265706f732f35353237373637392f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/55277679)

Table of content
================

[](#table-of-content)

- [Description](#description)
- [Installation](#installation)
    - Install with Composer
    - Add service provider to App
    - Add facade alias to App
    - Publish vendor with Artisan
    - Tables details
    - Make migration with Artisan
- [Usage](#usage)
    - [Groups](#groups)
        - Create, Delete, Update, Users list, Add member, Join request, Accept join, Decline join, Join request list
    - [Posts](#posts)
        - Create, Get, Update, Delete, Add to group, Group posts list, User posts list
    - [Comments](#comments)
        - Add, Get, Update, Delete
    - [Reporting](#reporting)
        - Report, Remove, Toggle , Count
    - [Likes](#likes)
        - Like, Unlike, Toggle, Count

Description
===========

[](#description)

This package allows you to add user groups *(groups, comment, like ...)* system to your Laravel 5 application.

Installation
============

[](#installation)

1. Via **Composer**, from the command line, run :

```
composer require musonza/groups
```

2. Add the service provider to `./config/app.php` in `providers` array, like :

```
    /*
     * Package Service Providers...
     */
    Musonza\Groups\GroupsServiceProvider::class,
```

3. You can use the facade for shorter code. Add this to `./config/app.php` at the end of `aliases` array :

```
    'Groups' => Musonza\Groups\Facades\GroupsFacade::class,
```

> Note : The class is bound to the ioC as Groups.

```
$groups = App::make('Groups');
```

4. From the command line, publish the assets:

```
php artisan vendor:publish
```

> Note : This will publish database migrations in `./database/migrations/`.

```
create_groups_table // main groups table
    id
    name
    description
    short_description
    image
    url
    user_id
    private
    conversation_id
    extra_info
    settings

# Usage

## Groups

1. ##### Create a group

```php
$group = Groups::create($userId, $data);

```

> Note : Accepted fields in $data array :

```
$data = [
  'name'              => '',
  'description'       => '', // optional
  'short_description' => '', // optional
  'image'             => '', // optional
  'private'           => 0,  // 0 (public) or 1 (private)
  'extra_info'        => '', // optional
  'settings'          => '', // optional
  'conversation_id'   => 0,  // optional if you want to add messaging to your groups this can be useful
];
```

2. ##### Delete a group

    [](#delete-a-group)

```
$group->delete();
```

3. ##### Update a group

    [](#update-a-group)

```
$group->update($updateArray);
```

4. ##### Get user instance with group relations

    [](#get-user-instance-with-group-relations)

```
$user = Groups::getUser($userId);
```

5. ##### Add members to group

    [](#add-members-to-group)

```
$group->addMembers([$userId, $userId2, ...]);
```

6. ##### Request to join a group

    [](#request-to-join-a-group)

```
$group->request($userId);
```

7. ##### Accept a group request

    [](#accept-a-group-request)

```
$group->acceptRequest($userId);
```

8. ##### Decline a group request

    [](#decline-a-group-request)

```
$group->declineRequest($userId);
```

9. ##### Group requests

    [](#group-requests)

```
$requests = $group->requests;
```

10. ##### How many groups a user is member of

    [](#how-many-groups-a-user-is-member-of)

```
$user = Groups::getUser($userId);
$count = $user->groups->count();
```

11. ##### Remove member(s) from group

    [](#remove-members-from-group)

```
$group->leave([$userId, $userId2, ...]);
```

Posts
-----

[](#posts)

1. ##### Create a post

    [](#create-a-post)

```
$post = Groups::createPost($data);
```

> Note : Acceptable values for Post $data array

```
$data = [
  'title'      => '',
  'user_id'    => 0,
  'body'       => '',
  'type'       => '',
  'extra_info' => '',
];
```

2. ##### Get post

    [](#get-post)

```
$post = Groups::post($postId);
```

3. ##### Update a post

    [](#update-a-post)

```
$post->update($data);
```

4. ##### Delete a post

    [](#delete-a-post)

```
$post->delete();
```

5. ##### Add a post to a group

    [](#add-a-post-to-a-group)

```
$group->attachPost($postId);
```

6. ##### Add multiple posts to a group

    [](#add-multiple-posts-to-a-group)

```
$group->attachPost([$postId, $postId2, ...]);
```

7. ##### Remove post from a group

    [](#remove-post-from-a-group)

```
$group->detachPost($postId);
```

8. ##### Group posts

    [](#group-posts)

```
$posts = $group->posts;

$posts = $group->posts()->paginate(5);

$posts = $group->posts()->orderBy('id', 'DESC')->paginate(5);
```

9. ##### User posts

    [](#user-posts)

```
$user = Groups::getUser($userId);

$posts = $user->posts;
```

Comments
--------

[](#comments)

> Note : Acceptable values for Comment $data array

```
$data = [
  'post_id' => 0,
  'user_id' => 0,
  'body'    => '',
];
```

1. ##### Add comment

    [](#add-comment)

```
$comment = Groups::addComment($data);
```

2. ##### Get comment

    [](#get-comment)

```
$comment = Groups::comment($commentId);

```

3. ##### Update a comment

    [](#update-a-comment)

```
$comment->update($data);
```

4. ##### Delete a comment

    [](#delete-a-comment)

```
$comment->delete();
```

Reporting
---------

[](#reporting)

1. ##### Report a comment or post

    [](#report-a-comment-or-post)

```
$comment->report($userIdOfReporter);
$post->report($userIdOfReporter);
```

2. ##### Remove a post or comment report

    [](#remove-a-post-or-comment-report)

```
$post->removeReport($userId);
$comment->removeReport($userId);
```

3. ##### Toggle report/unreport a post or comment

    [](#toggle-reportunreport-a-post-or-comment)

```
$post->toggleReport($userId);
$comment->toggleReport($userId);
```

4. ##### Post or Comment Report count

    [](#post-or-comment-report-count)

```
$commentReports = $comment->reportsCount;
$postReports = $post->reportsCount;
```

Likes
-----

[](#likes)

1. ##### Like a post or comment

    [](#like-a-post-or-comment)

```
$post->like($userId);
$comment->like($userId);
```

2. ##### Unlike a post or comment

    [](#unlike-a-post-or-comment)

```
$post->unlike($userId);
$comment->unlike($userId);
```

3. ##### Toggle like/unlike a post or comment

    [](#toggle-likeunlike-a-post-or-comment)

```
$post->toggleLike($userId);
$comment->toggleLike($userId);
```

4. ##### Post or Comment likes count

    [](#post-or-comment-likes-count)

```
$postLikes = $post->likesCount;
$commentLikes = $comment->likesCount;
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~351 days

Total

5

Last Release

2287d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/323d3a96552f5802412941c11f785c4a1eb7d82037a7e42b75cb6256f4857564?d=identicon)[musonza](/maintainers/musonza)

---

Top Contributors

[![musonza](https://avatars.githubusercontent.com/u/3452388?v=4)](https://github.com/musonza "musonza (4 commits)")[![Deefaze](https://avatars.githubusercontent.com/u/6393617?v=4)](https://github.com/Deefaze "Deefaze (2 commits)")[![akwetey](https://avatars.githubusercontent.com/u/23408703?v=4)](https://github.com/akwetey "akwetey (1 commits)")[![jny986](https://avatars.githubusercontent.com/u/37679074?v=4)](https://github.com/jny986 "jny986 (1 commits)")

---

Tags

groupslaravellaravel-groupsphp-groupssocial-networklaravelgroupsconversations

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/musonza-groups/health.svg)

```
[![Health](https://phpackages.com/badges/musonza-groups/health.svg)](https://phpackages.com/packages/musonza-groups)
```

###  Alternatives

[lab404/laravel-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

2.3k16.4M48](/packages/lab404-laravel-impersonate)[santigarcor/laratrust

This package provides a flexible way to add Role-based Permissions to Laravel

2.3k5.4M43](/packages/santigarcor-laratrust)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
