Send Email to Multiple Users based on Multiple selected roles
Hi Team, I have an issue that I need some assistance with. I have a project form that I am assigning projects to departments, I have used the Spatie Permissions and while assigning the project managers, I am selecting them based on their roles because there are several of them with the same Permission.
My challenge is that when I send the mail, I choose their roles and only the first user with that role gets a notification and the rest don't. Is there someone who can assist kindly?
public function store(StoreProjectRequest $request)
{
$project->projectOwners()->attach($request->projectOwnerRoles);
Notification::send($project->projectOwners, new ProjectAssignedNotification($project));
return to_route('project.show', $project)->with('Project Created Successfully.');
}
since it will display the roles when selecting, on the store method, you can perform the below and it will serve the same purpose:
public function store(StoreProjectRequest $request)
{
$project->projectOwners()->attach($request->projectOwnerRoles);
Notification::send($project->projectOwners,
new ProjectAssignedNotification($project));
return to_route('project.show', $project)->with('Project Created Successfully.');
}