示例#1
0
 /**
  * Attach a user to a given team based on their invitation.
  *
  * @param  string  $invitationId
  * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
  * @return void
  */
 public function attachUserToTeamByInvitation($invitationId, $user)
 {
     $userModel = get_class($user);
     $inviteModel = get_class((new $userModel())->invitations()->getQuery()->getModel());
     $invitation = (new $inviteModel())->where('token', $invitationId)->first();
     if ($invitation) {
         $invitation->team->users()->attach([$user->id], ['role' => Spark::defaultRole()]);
         $user->switchToTeam($invitation->team);
         $invitation->delete();
     }
 }
 /**
  * Customize the roles that may be assigned to team members.
  *
  * @return void
  */
 protected function customizeRoles()
 {
     Spark::defaultRole('member');
     Spark::roles(['admin' => 'Administrator', 'member' => 'Member']);
 }
示例#3
0
 /**
  * Join the team with the given ID.
  *
  * @param  int  $teamId
  * @return void
  */
 public function joinTeamById($teamId)
 {
     $this->teams()->attach([$teamId], ['role' => Spark::defaultRole()]);
     $this->currentTeam();
     event(new JoinedTeam($this, $this->teams()->find($teamId)));
 }
示例#4
0
 /**
  * Join the team with the given ID.
  *
  * @param  int  $teamId
  * @return void
  */
 public function joinTeamById($teamId)
 {
     $this->teams()->attach([$teamId], ['role' => Spark::defaultRole()]);
     $this->currentTeam();
 }
示例#5
0
 /**
  * {@inheritdoc}
  */
 public function handle($team, $user, $role = null)
 {
     $team->users()->attach($user, ['role' => $role ?: Spark::defaultRole()]);
     event(new TeamMemberAdded($team, $user));
 }