1. Go to this page and download the library: Download jurager/teams 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/ */
jurager / teams example snippets
namespace App\Providers;
use Jurager\Teams\Traits\HasTeams;
class User extends Model {
use HasTeams;
}
// Access the team's owner...
$team->owner
// Get all the team's users, excluding owner
$team->users()
// Get all the team's users, including the owner...
$team->allUsers()
// Determine if the given user is a team member...
$team->hasUser((object) $user)
// Get all the abilities belong to the team.
$team->abilities()
// Get all the team's roles.
$team->roles()
// Get the role from the team by role id or name
$team->findRole((int|string) $id)
// Return the user role object from the team
$team->userRole((object) $user)
// Add new role to the team
$team->addRole((string) $name, (array) $capabilities)
// Update the role in the team
$team->updateRole((string) $name, (array) $capabilities)
// Deletes the given role from team
$team->deleteRole((string) $name)
// Get all groups of the team.
$team->groups()
// Get team group by its code
$team->group((string) $code)
// Add new group to the team
$team->addGroup((string) $code, (string) $name)
// Delete group from the team
$team->deleteGroup((string) $code)
// Determine if the team has a member with the given email address...
$team->hasUserWithEmail((array) $emailAddress)
// Determine if the given user is a team member with the given permission...
$team->userHasPermission((object) $user, (string|array) $permission, (bool) $
// Access the team's that a user belongs to...
$user->teams : Illuminate\Database\Eloquent\Collection
// Access all of a user's owned teams...
$user->ownedTeams : Illuminate\Database\Eloquent\Collection
// Access all the team's (including owned teams) that a user belongs to...
$user->allTeams() : Illuminate\Database\Eloquent\Collection
// Determine if a user owns a given team...
$user->ownsTeam((object) $team) : bool
// Determine if a user belongs to a given team...
$user->belongsToTeam((object) $team) : bool
// Get the role that the user is assigned on the team...
$user->teamRole((object) $team) : \Jurager\Teams\Role
// Determine if the user has the given role on the given team...
$user->hasTeamRole((object) $team, (string|array) 'admin', (bool) $// Forbid an ability for user to action on certain model, used in case if global permission or role allowing this action
$user->forbidTeamAbility((object) $team, (string) 'server:edit', (object) $server) : bool
// Add new group to the team
$team->addGroup((string) $code, (string) $name)
// Delete group from the team
$team->deleteGroup((string) $code)
// Get all groups of the team.
$team->groups();
// Get team group by its code
$team->group((string) $code);
// Get all group users
$team->group((string) $code)->users();
// Attach users or user to a group
$team->group((string) $code)->attachUser((Collection|Model) $user);
// Detach users or user from group
$team->group((string) $code)->detachUser((Collection|Model) $user);
// Add an ability for user to action on certain model within team group, if permission is not found, will create a new one
$user->allowTeamAbility((object) $team, (string) 'server:edit', (object) $server, (object|null) $group));
// Forbid an ability for user to action on certain model within team group
$user->forbidTeamAbility((object) $team, (string) 'server:edit', (object) $server, (object|null) $group);
// Delete user ability to action on certain model within team group
$user->deleteTeamAbility((object) $team, (string) 'server:edit', (object) $server, (object|null) $group);
// Determinate if user can perform an action
$user->hasTeamAbility((object) $team, (string) 'server:edit', (object) $server)