musonza/groups 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

musonza/groups

Composer 安装命令:

composer require musonza/groups

包简介

Laravel 5 user groups package

README 文档

README

Build Status Downloads Packagist StyleCI

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

Description

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

Installation

  1. Via Composer, from the command line, run :
composer require musonza/groups
  1. Add the service provider to ./config/app.php in providers array, like :
    /*
     * Package Service Providers...
     */
    Musonza\Groups\GroupsServiceProvider::class,
  1. 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');
  1. 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
];
  1. Delete a group
$group->delete();
  1. Update a group
$group->update($updateArray);
  1. Get user instance with group relations
$user = Groups::getUser($userId); 
  1. Add members to group
$group->addMembers([$userId, $userId2, ...]);
  1. Request to join a group
$group->request($userId);
  1. Accept a group request
$group->acceptRequest($userId);
  1. Decline a group request
$group->declineRequest($userId);
  1. Group requests
$requests = $group->requests;
  1. How many groups a user is member of
$user = Groups::getUser($userId); 
$count = $user->groups->count();
  1. Remove member(s) from group
$group->leave([$userId, $userId2, ...]);

Posts

  1. Create a post
$post = Groups::createPost($data);

Note : Acceptable values for Post $data array

$data = [
  'title'      => '', 
  'user_id'    => 0, 
  'body'       => '', 
  'type'       => '', 
  'extra_info' => '',
];
  1. Get post
$post = Groups::post($postId);
  1. Update a post
$post->update($data);
  1. Delete a post
$post->delete();
  1. Add a post to a group
$group->attachPost($postId);
  1. Add multiple posts to a group
$group->attachPost([$postId, $postId2, ...]);
  1. Remove post from a group
$group->detachPost($postId);
  1. Group posts
$posts = $group->posts;

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

$posts = $group->posts()->orderBy('id', 'DESC')->paginate(5);
  1. User posts
$user = Groups::getUser($userId);

$posts = $user->posts;

Comments

Note : Acceptable values for Comment $data array

$data = [
  'post_id' => 0,  
  'user_id' => 0, 
  'body'    => '',
];
  1. Add comment
$comment = Groups::addComment($data);
  1. Get comment
$comment = Groups::comment($commentId);
  1. Update a comment
$comment->update($data);
  1. Delete a comment
$comment->delete();

Reporting

  1. Report a comment or post
$comment->report($userIdOfReporter);
$post->report($userIdOfReporter);
  1. Remove a post or comment report
$post->removeReport($userId);
$comment->removeReport($userId);
  1. Toggle report/unreport a post or comment
$post->toggleReport($userId);
$comment->toggleReport($userId);
  1. Post or Comment Report count
$commentReports = $comment->reportsCount;
$postReports = $post->reportsCount;

Likes

  1. Like a post or comment
$post->like($userId);
$comment->like($userId);
  1. Unlike a post or comment
$post->unlike($userId);
$comment->unlike($userId);
  1. Toggle like/unlike a post or comment
$post->toggleLike($userId);
$comment->toggleLike($userId);
  1. Post or Comment likes count
$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 我们能提供哪些服务?
定制开发 / 二次开发

基于 musonza/groups 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.11k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 69
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 69
  • Watchers: 9
  • Forks: 16
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-02