I'm using mailgun API and batch sending , in order to properly send batch mails with recipent variables I must provide a valid JSON-encoded dictionary, where key is a plain recipient address and value is a dictionary with variables.
The JSON object I wanna obtain is as follows:
'{ "bob@example.com": {"username":"Bob", "id":1} ,
{ "pete@example.com": {"first":"Pete", "id":2} ,'
This is what I have so far (pseudocode):
$subs = Sub::all();
foreach($subs as $sub)
{
$username = mailName($email->email);
$id = $sub->id;
}
How could I do this, is it possible to do with laravel collection methods?
Thanks in advance and sorry for noob question.