iam_principal_group = $iam_principal_group; $this->program = $program; $this->user_fname = $user_fname; $this->user_lname = $user_lname; } /** * Get the message envelope. */ // public function envelope(): Envelope // { // return new Envelope( // subject: 'Group Member Email', // ); // } /** * Get the message content definition. */ // public function content(): Content // { // return new Content( // view: 'view.name', // ); // } public function build() { // Access iam_principal_group and program directly $iam_principal_group = $this->iam_principal_group; $program = $this->program; $user_fname = $this->user_fname; $user_lname = $this->user_lname; // dd($user_fname,$user_lname); $groupMemberNames = json_decode($iam_principal_group->group_member_name); $groupMemberEmails = json_decode($iam_principal_group->group_member_email); // Loop through each group member foreach ($groupMemberEmails as $key => $email) { $data = [ 'group_member_name' => $groupMemberNames[$key], 'group_member_email' => $email, 'start_date' => $iam_principal_group->start_date, 'program_title' => $program->program_title, 'Duration' => $iam_principal_group->week, 'first_name' => $this->user_fname, 'last_name' => $this->user_lname ]; // dd($data); // Send an email to the current group member $this->subject('Program Invitation Mail') ->to($email) ->view('Frontend.Templates.group_member_invitation', ["content" => $data]); } } /** * Get the attachments for the message. * * @return array */ public function attachments(): array { return []; } }