Example #1
0
 /**
  * Create a new invitation instance.
  *
  * @param  \Laravel\Spark\Team  $team
  * @param  string  $email
  * @param  \Illuminate\Contracts\Auth\Authenticatable|null  $invitedUser
  */
 protected function createInvitation($team, $email, $invitedUser)
 {
     return $team->invitations()->create(['id' => Uuid::uuid4(), 'user_id' => $invitedUser ? $invitedUser->id : null, 'email' => $email, 'token' => str_random(40)]);
 }
 /**
  * Verify that the given e-mail is not already invited.
  *
  * @param  \Illuminate\Validation\Validator  $validator
  * @param  \Laravel\Spark\Team  $team
  * @return $this
  */
 protected function verifyEmailNotAlreadyInvited($validator, $team)
 {
     if ($team->invitations()->where('email', $this->email)->exists()) {
         $validator->errors()->add('email', 'That user is already invited to the team.');
     }
     return $this;
 }