Spark - Extend CreateTeam function with more parameters
Hi,
I am struggling with being able top extend a function that is called when a new user registers with a team on a spark environment.
I am wanting to include a Team Slug field which the user has to complete on the main registration form before being able to register. I have successfully added the field to the db using a migration script, I have added the field to the view and have been able to extend the validation functionality which is cool.
I am now struggling with the function below as you can see the else statement hard codes what parameters to pass through, in this case, it is only passing the name:
Spark::interact(CreateTeam::class, [$user, ['name' => $request->team]]);
I would like a way to be able to extend or swap this function so it can accept my slug parameter, or a simple array of options:
Spark::interact(CreateTeam::class, [$user, ['name' => $request->team, 'slug' => $request->slug]]);
Here is the function I am wanting to swap:
/**
* Attach the user to a team if an invitation exists, or create a new team.
*
* @param RegisterRequest $request
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @return void
*/
protected function configureTeamForNewUser(RegisterRequest $request, $user)
{
if ($invitation = $request->invitation()) {
Spark::interact(AddTeamMember::class, [$invitation->team, $user]);
$invitation->delete();
} else {
Spark::interact(CreateTeam::class, [$user, ['name' => $request->team]]);
}
$user->currentTeam();
}
Can anyone confirm if this is at all possible?
Thanks in advance
Please or to participate in this conversation.