91 lines
2.6 KiB
PHP
91 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Mail\Frontend;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class GroupMemberEmail extends Mailable
|
|
{
|
|
use Queueable, SerializesModels;
|
|
public $iam_principal_group;
|
|
public $program;
|
|
public $user_fname;
|
|
public $user_lname;
|
|
/**
|
|
* Create a new message instance.
|
|
*/
|
|
public function __construct($iam_principal_group,$program,$user_fname,$user_lname)
|
|
{
|
|
$this->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<int, \Illuminate\Mail\Mailables\Attachment>
|
|
*/
|
|
public function attachments(): array
|
|
{
|
|
return [];
|
|
}
|
|
}
|