vendredi 1 décembre 2017

Laravel - Multiple Arrays for Multiple Recipients (Mailable/Notifications)

I'm looking for a little bit of advice for a project and an interesting predicament I've put myself in.

I have multiple fields in my shipment model, they are:

  • shipto_id
  • shipfrom_id
  • billto_id

They all link (through different relationships) to my customer model:

public function billtoAccount()
{
    return $this->belongsTo('App\Customer', 'bill_to');
}

public function shiptoAccount()
{
    return $this->belongsTo('App\Customer', 'ship_to');
}

public function shipfromAccount()
{
    return $this->belongsTo('App\Customer', 'ship_from');
}

and these customers (in reality would likely be better described as customer accounts (these are NOT USER ACCOUNTS, they're more just like a profile for each company that business is done with)) can have a multitude of users associated with them.

 public function users()
{
    return $this->belongsToMany(User::class);
}

Now, while I know how to send off mailables and notifications, I was curious to know how I would go about sending off those to multiple user's emails. So let me describe the following: Something is created and the following customers (and in turn, their users) are referenced.

  • (billto_id) - Customer Account 1 - User 1 (email1@example.com)
  • (shipto_id) - Customer Account 2 - User 2 (email2@example.com) & User 3 (email3@example.com)
  • (shipfrom_id) - Customer Account 37 - User 6 (email4@example.com)

Now, how would I go about moving the emails of the users over to an array of emails to have a notification or mailable sent to them?

Thank you so much in advance for any help or suggestions you can provide!

Matt



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2njE9bL
via IFTTT

Aucun commentaire:

Enregistrer un commentaire