Have you tried using the Spark::swap() method for that class::method? https://spark.laravel.com/docs/4.0/customization
Assigning user to correct team role when sending invitation
Hi,
I have added a couple of custom team roles to the sparkServiceProvider e.g:
Spark::useRoles([
'basic' => 'Basic',
'advanced' => 'Advanced',
]);
When a team owner goes to the membership page to send an email invitation to a new member. I am thinking of extending the vue component and adding a 'role' field to the spark form object so the team owner can select the role for invited users.
I will then need to add a role column to the invitations database table so that when the invitation is saved then the selected role is also saved. (Would need to edit a couple of source files here to make sure role is also saved when invitation is created).
In laravel\spark\src\Interactions\Auth\Register.php @ configureTeamForNewUser
If an invitation is present then Spark::interact(AddTeamMember::class, [$invitation->team, $user]); is called.
The handle method of laravel\spark\src\Interactions\Settings\Teams\AddTeamMember.php is:
public function handle($team, $user, $role = null)
{
$team->users()->attach($user, ['role' => $role ?: Spark::defaultRole()]);
event(new TeamMemberAdded($team, $user));
}
So as it stands no $role variable is passed to this method so it will always be Spark::defaultRole(). Will Spark::defaultRole() still be 'member' even if I have added useRoles to the sparkServiceProvider?
If I edit Auth\Register.php changing it to:
Spark::interact(AddTeamMember::class, [$invitation->team, $user, $invitation->role]);
Then I believe it should work.
However ideally I do not want to edit the source files. Is there a better way to achieve this?
Thanks
Please or to participate in this conversation.