dev-master
9999999-devLaravel 5 user groups package
MIT
The Requires
by Tinashe Musonza
laravel groups conversations
v1.0.2
1.0.2.0Laravel 5 user groups package
MIT
The Requires
by Tinashe Musonza
laravel groups conversations
Wallogit.com
2017 © Pedro Peláez
Laravel 5 user groups package
This package allows you to add user groups (groups, comment, like ...) system to your Laravel 5 application., (*2)
composer require musonza/groups
./config/app.php in providers array, like : /*
* Package Service Providers...
*/
Musonza\Groups\GroupsServiceProvider::class,
./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., (*3)
$groups = App::make('Groups');
php artisan vendor:publish
Note : This will publish database migrations in
./database/migrations/., (*4)
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 :, (*5)
$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 ];
$group->delete();
$group->update($updateArray);
$user = Groups::getUser($userId);
$group->addMembers([$userId, $userId2, ...]);
$group->request($userId);
$group->acceptRequest($userId);
$group->declineRequest($userId);
$requests = $group->requests;
$user = Groups::getUser($userId); $count = $user->groups->count();
$group->leave([$userId, $userId2, ...]);
$post = Groups::createPost($data);
Note : Acceptable values for Post $data array, (*6)
$data = [ 'title' => '', 'user_id' => 0, 'body' => '', 'type' => '', 'extra_info' => '', ];
$post = Groups::post($postId);
$post->update($data);
$post->delete();
$group->attachPost($postId);
$group->attachPost([$postId, $postId2, ...]);
$group->detachPost($postId);
$posts = $group->posts;
$posts = $group->posts()->paginate(5);
$posts = $group->posts()->orderBy('id', 'DESC')->paginate(5);
$user = Groups::getUser($userId); $posts = $user->posts;
Note : Acceptable values for Comment $data array, (*7)
$data = [ 'post_id' => 0, 'user_id' => 0, 'body' => '', ];
$comment = Groups::addComment($data);
$comment = Groups::comment($commentId);
$comment->update($data);
$comment->delete();
$comment->report($userIdOfReporter); $post->report($userIdOfReporter);
$post->removeReport($userId); $comment->removeReport($userId);
$post->toggleReport($userId); $comment->toggleReport($userId);
$commentReports = $comment->reportsCount; $postReports = $post->reportsCount;
$post->like($userId); $comment->like($userId);
$post->unlike($userId); $comment->unlike($userId);
$post->toggleLike($userId); $comment->toggleLike($userId);
$postLikes = $post->likesCount; $commentLikes = $comment->likesCount;
Laravel 5 user groups package
MIT
laravel groups conversations
Laravel 5 user groups package
MIT
laravel groups conversations