@ash92 your question is not clear
How to send email to a specific user with specific data from database tables?
I have three tables. One is users, where I have stored property_id, email and user_type. Another one is bills where i have stored bill information with property_id. Last one is property. Where I have stored all the properties. i am creating the bill against properties. i have many records in my bills and users tables. if I send email of bills it sends all the records from bills table to all the users from users table. But I want to send bill to specific user which match with property_id. property_id of users id and property_id bills table I need to bind and send email to that specific users with the specific bills information from bills table. How to do that? I got stuck here. Anyone please?
$users = User::where('user_type', 'residence_admin')->get();
foreach($users as $user) {
$data["email"] = $user->email;
$data["title"] = "From Admin";
$data["body"] = "Bill To Pay";
$pdf = PDF::loadView('emails.myTestMail', $data);
$mail = Mail::send('emails.myTestMail', $data, function($message) use($data, $pdf) {
$message->to($data["email"], $data["email"])
->subject($data["title"])
->attachData($pdf->output(), "Bill.PDF");
});
}
Please or to participate in this conversation.