PHP code example of etsh / groupable

1. Go to this page and download the library: Download etsh/groupable 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/ */

    

etsh / groupable example snippets


composer 

Etsh\Groupable\GroupableServiceProvider::class

art migrate

use Etsh\Groupable\Traits\IsGroup;

class Group extends Model
{
    use IsGroup

    protected $groupable_models = [
        GroupableContent::class,
    ];

    protected $groupable_roles = [
        'admin',
    ];

    ...

use Etsh\Groupable\Traits\IsGroup;

class Group extends Model
{
    use IsGroupable

use Etsh\Groupable\Traits\CanJoinGroups;

class User extends Authenticatable
{
    use CanJoinGroups;

$group->addContent($groupable_content);

$group->removeContent($groupable_content);

$group->content();

$group->content([GroupableContentType1::class, GroupableContentType2::class]);

$group->join($user);

$group->leave($user);

$group->members();

$group->membersByRole('admin');

$user->belongsToGroup($group);

$group->grant($user, $role);

$group->revoke($user, $role);

$user->hasGroupRole($group, $role);

$user->groupRoles($group);

$group->types();

$group->roles();

$groupable_content->groups();