I want to send a confirmation email to the user who requested the service, but when I try to pass the email and name the class to send mail, I get the following error:
Type error: Argument 2 passed to Illuminate\Mail\Mailer::send() must be of the type array, object given
The method I am using to send the mail to the user is the following:
$dat = \DB::table('vacations')->select('users.email', 'users.name')->join('users','users.id','=','vacations.user_id')
->where(['vacations.id' => $request->vacation_id])
->get();
$name[]=$dat[0]->name;
//dd($dat[0]->email,$name);
Mail::send("correo.aprobado", $dat, function($message) use ($dat,$name){
$message->to(['email'=>$dat[0]],['name'=>$dat[0]])
->subject("enhorabuena");
});
the output of the variable $ dat is this:
Collection {#265 ▼
#items: array:1 [▼
0 => {#256 ▼
+"email": "[email protected]"
+"name": "user"
}
]
}
Thank you very much for your attention.