I'm trying to send an email to multiple emails, so I did a query to my users tables but the result is an array with keys that don't work mail->to()
.
I need an array like this: $owners = ['[email protected]', '[email protected]','[email protected]'];
from database.
My query:
$owners = DB::table('users')->select('email')->where('active', 1)->where('userType', 1)->get();
I also try use ->toArray()
but comes with keys.
Email:
Mail::send('email-view', $data, function($message) use ($data, $owners)
{
$message->from('[email protected]' , 'FROM');
$message->to($owners)->subject('subject');
});
$owners = DB::table('users')->where('active', 1)->where('userType', 1)->pluck('email')->toArray();