Example #1
0
 /**
  * Create a new team.
  *
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $user = $request->user();
     if (Spark::$validateNewTeamsWith) {
         $this->callCustomValidator(Spark::$validateNewTeamsWith, $request);
     } else {
         $this->validate($request, ['name' => 'required|max:255']);
     }
     $team = $this->teams->create($user, ['name' => $request->name]);
     return $this->teams->getAllTeamsForUser($user);
 }
Example #2
0
 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  bool  $withSubscription
  * @return \Illuminate\Http\Response
  */
 protected function register(Request $request, $withSubscription = false)
 {
     $this->validateRegistration($request, $withSubscription);
     $user = $this->users->createUserFromRegistrationRequest($request, $withSubscription);
     if ($request->team_name) {
         $team = $this->teams->create($user, ['name' => $request->team_name]);
     }
     if ($request->invitation) {
         $this->teams->attachUserToTeamByInvitation($request->invitation, $user);
     }
     event(new Registered($user));
     if ($withSubscription) {
         event(new Subscribed($user));
     }
     Auth::login($user);
     return response()->json(['path' => $this->redirectPath()]);
 }