PHP code example of mohiqssh / groups

1. Go to this page and download the library: Download mohiqssh/groups library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mohiqssh / groups example snippets


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

    'Groups' => Mohiqssh\Groups\Facades\GroupsFacade::class,

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

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

$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);

$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;

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

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

$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;
console
php artisan vendor:publish