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...
// Accepts user object
$team->hasUser($user)
// Adds a user to the team with a specified role by role ID or code
$team->addUser($user, $role_keyword)
// Update the role of a specific user within the team
$team->updateUser($user, $role_keyword)
// Remove the given user from the team.
$team->deleteUser($user);
// Get all the abilities belong to the team.
$team->abilities()
// Get all the team's roles.
$team->roles()
// Return the user role object from the team
$team->userRole($user)
// Check if the team has a specific role by ID or code or any roles at all if null
$team->hasRole($role_keyword)
// Get the role from the team by role id or code
$team->getRole($role_keyword)
// Add new role to the team
$team->addRole($code, $permissions, $name, $description)
// Update the role in the team
// Name and description is nullable when no changes needed
$team->updateRole($role_keyword, $permissions, $name, $description)
// Deletes the given role from team
$team->deleteRole($role_keyword)
// Get all groups of the team.
$team->groups()
// Get team group by its id or code
$team->getGroup($group_keyword)
// Add new group to the team
$team->addGroup($code, $permissions, $name)
// Update the group in the team
$team->updateGroup($group_keyword, $permissions, $name)
// Delete group from the team
$team->deleteGroup($group_keyword)
// Determine if the team has a member with the given email address...
$team->hasUserWithEmail($email)
// Determine if the given user is a team member with the given permission...
// $
// Access the teams that a user belongs to...
$user->teams
// Access all of a user's owned teams...
$user->ownedTeams
// Access all the team's (including owned teams) that a user belongs to...
$user->allTeams()
// Determine if a user owns a given team...
$user->ownsTeam($team)
// Determine if a user belongs to a given team...
$user->belongsToTeam($team)
// Get the role that the user is assigned on the team...
$user->teamRole($team)
// Determine if the user has the given role (or roles if array passed) on the given team...
// $e permission in the array are for user to action on certain model, used in case if global ability or role allowing this action
$user->forbidTeamAbility($team, 'server:edit', $server)
// Add new group to the team
// If $name is null, str::studly of $code will be used
$team->addGroup($code, $permissions, $name)
// Update the group in the team, if permissions is empty array all exiting permissions will be detached
// If $name is null, str::studly of $code will be used
$team->updateGroup($group_keyword, $permissions, $name)
// Delete group from the team
$team->deleteGroup($group_keyword)
// Get all groups of the team.
$team->groups();
// Check if the team has a specific group by ID or code or any groups at all if null passed
$team->hasGroup($group_keyword)
// Get team group by its code
$group = $team->getGroup($group_keyword);
// Get all group users
$group->users();
// Attach users or user to a group
$group->attachUser($user);
// Detach users or user from group
$group->detachUser($user);