musonza/groups
Composer 安装命令:
composer require musonza/groups
包简介
Laravel 5 user groups package
README 文档
README
Table of content
- Description
- 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
- Groups
- Create, Delete, Update, Users list, Add member, Join request, Accept join, Decline join, Join request list
- Posts
- Create, Get, Update, Delete, Add to group, Group posts list, User posts list
- Comments
- Add, Get, Update, Delete
- Reporting
- Report, Remove, Toggle , Count
- Likes
- Like, Unlike, Toggle, Count
- Groups
Description
This package allows you to add user groups (groups, comment, like ...) system to your Laravel 5 application.
Installation
- Via Composer, from the command line, run :
composer require musonza/groups
- Add the service provider to
./config/app.phpinprovidersarray, like :
/* * Package Service Providers... */ Musonza\Groups\GroupsServiceProvider::class,
- You can use the facade for shorter code.
Add this to
./config/app.phpat the end ofaliasesarray :
'Groups' => Musonza\Groups\Facades\GroupsFacade::class,
Note : The class is bound to the ioC as Groups.
$groups = App::make('Groups');
- 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 ];
$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, ...]);
Posts
$post = Groups::createPost($data);
Note : Acceptable values for Post $data array
$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;
Comments
Note : Acceptable values for Comment $data array
$data = [ 'post_id' => 0, 'user_id' => 0, 'body' => '', ];
$comment = Groups::addComment($data);
$comment = Groups::comment($commentId);
$comment->update($data);
$comment->delete();
Reporting
$comment->report($userIdOfReporter); $post->report($userIdOfReporter);
$post->removeReport($userId); $comment->removeReport($userId);
$post->toggleReport($userId); $comment->toggleReport($userId);
$commentReports = $comment->reportsCount; $postReports = $post->reportsCount;
Likes
$post->like($userId); $comment->like($userId);
$post->unlike($userId); $comment->unlike($userId);
$post->toggleLike($userId); $comment->toggleLike($userId);
$postLikes = $post->likesCount; $commentLikes = $comment->likesCount;
musonza/groups 适用场景与选型建议
musonza/groups 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.11k 次下载、GitHub Stars 达 69, 最近一次更新时间为 2016 年 04 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「groups」 「conversations」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 musonza/groups 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 musonza/groups 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 musonza/groups 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Groups Plugin for NetCommons
Talk is a Laravel based realtime messaging, chatting and conversation system. It helps to develop users messaging, chatting and conversations in easy way.
User handling for PHP applications.
Customers management for Symfony projects.
Talk is a Laravel 5 based realtime messaging, chatting and conversation system. It helps to develop users messaging, chatting and conversations in easy way.
Laravel 5 user groups package originally by musonza/groups. I fork it and made some upgrades in the code & mold it according to my project needs.
统计信息
- 总下载量: 3.11k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 69
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-02