I have a form, in which when I fill and submit, it's sent email to multiple recipient, when I do that I get this error htmlspecialchars() expects parameter 1 to be string, array given (View: C:\wamp64\www\star\resources\views\emails\email_invite_template.blade.php below is my code:
The Form
<input name="iname[]" class="form-control" type="text" placeholder="Name" >
<input name="iemail[]" class="form-control" type="text" placeholder="Email" >
<input type="submit" value="Send Invite" >
SendEmail
class SendEmail extends Mailable
{
use Queueable, SerializesModels;
public $data;
public function __construct($data)
{
$this->data = $data;
}
public function build()
{
return $this->subject('Invitation to Mase')
->markdown('emails.email_invite_template')
->with('data', $this->data);
}
}
Controller
public function storeInvite(Request $request)
{
$eventid = $request->get('eventid');
$iname = $request->get('iname');
$iemail = $request->get('iemail');
$data = array(
'dname' => $request->iname,
'demail' => $request->iemail
);
foreach($data['demail'] as $user){
Mail::to($user)->send(new SendEmail($data));
}
return redirect()->back()->with('status','Invitation sent to users');
}
Email Template (email_invite_template.php)
@component('mail::message')
<p>Hi, {{ $data['dname'] }}</p>
<p>You have just been invited to an event below is your invitation code:</p>
<p></b>{{ $data['demail'] }}</b></p>
Thanks,<br>
{{ config('app.name') }}
@endcomponent
Thanks