This should be a mail service. Ideally working towards an interface.
Something like:
$shop = Shop::where('postcode', '=', 44444)->first();
AppMailer::send($shop);
AppMailer::bulk(Shop::where('postcode', '=', 44444));
Service method, over in your service class
// Single send
function send(IMailable $mailable)
{
// do mail stuff here
// the mail service doesn't even need to care if its
// eloquent or not
$this->doSomething($mailable->email);
}
// Bulk send
function bulk(Collection $mailables)
{
foreach ($mailables as $mailable)
{
if($mailable instanceof IMailable)
{
$this->send($mailable);
}
}
}
IMailable, over in your IMailer interface class
interface IMailable {
public function getEmailAddress();
public function getName();
}
Shop class somewhere
class Shop extends Eloquent implements IMailable {
// bla bla your normal attributes for a shop
// add some special attributes to statisfy the mailable contract
public function getEmailAddress()
{
return $this->email;
}
public function getName()
{
return $this->streetNumber . ' ' . $this->streetName;
}
}
The good thing about all this is that later if you want to email Cafes as well as Shops you just need to make sure your Cafe class implements IMailable and you are laughing all the way to the shop, and well cafe.