/**
  * Update the given team's photo.
  *
  * @param  UpdateTeamPhotoRequest  $request
  * @param  \Laravel\Spark\Team  $team
  * @return Response
  */
 public function update(UpdateTeamPhotoRequest $request, $team)
 {
     // We will store the profile photos on the "public" disk, which is a convention
     // for where to place assets we want to be publicly accessible. Then, we can
     // grab the URL for the image to store with this user in the database row.
     $file = $request->file('photo');
     $disk = Storage::disk('public');
     $path = $file->hashName('profiles');
     // We will use an image manipulation library to resize the given team photo and
     // get it ready for storage. We'll also get the "hash name" of this photo as
     // it serves as a unique identifier for the image and is safe for storage.
     $disk->put($path, $this->toImage($file));
     $team->forceFill(['photo_url' => $disk->url($path)])->save();
 }
Example #2
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)]);
 }
 /**
  * Determine if the team exceeds the maximum team memebrs for the plan.
  *
  * @param  \Laravel\Spark\Team  $team
  * @param  \Laravel\Spark\Plan  $plan
  * @return bool
  */
 protected function exceedsMaximumTeamMembers($team, $plan)
 {
     return !is_null($plan->teamMembers) ? $plan->teamMembers < $team->totalPotentialUsers() : false;
 }
 /**
  * Remove the given team member from the team.
  *
  * @param  RemoveTeamMemberRequest  $request
  * @param  \Laravel\Spark\Team  $team
  * @param  mixed  $member
  * @return Response
  */
 public function destroy(RemoveTeamMemberRequest $request, $team, $member)
 {
     $team->users()->detach($member->id);
     event(new TeamMemberRemoved($team, $member));
 }
 /**
  * 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;
 }