PHP code example of messerli90 / teamwork
1. Go to this page and download the library: Download messerli90/teamwork 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/ */
messerli90 / teamwork example snippets
Teamwork::inviteToTeam($user, $team, callable $success)
Teamwork::hasPendingInvite($user, $team) // bool
Teamwork::getInviteFromAcceptToken($token)
Teamwork::getInviteFromDenyToken($token)
Teamwork::acceptInvite(TeamInvite $invite)
Teamwork::denyInvite(TeamInvite $invite)
use Messerli90\Teamwork\HasMembers;
class Team extends Model {
use HasMembers;
}
$team = App\Team::find(1);
$user = App\User::find(2);
$team->hasUser($user); // bool
use Messerli90\Teamwork\HasTeams;
class User extends Authenticatable {
use HasTeams;
}
$user = App\User::find(1);
// Owns ANY team
$user->ownsTeam(); // bool
// Owns provided team
$team = App\Team::find(1);
$user->ownsTeam($team); // bool
$user = App\User::find(1);
$team = App\Team::find(1);
$role = 'member' // Default allowed roles: member, owner, admin, moderator
$user->attachTeam($team, $role);
$user = App\User::find(1);
$team = App\Team::find(1);
$user->detachTeam($team);
$user = App\User::find(1);
$team = App\Team::find(1);
$user->switchRole($team, 'moderator')
bash
php artisan vendor:publish --provider="Messerli90\Teamwork\TeamworkServiceProvider" --tag=config
bash
php artisan migrate