Skip to content

Instantly share code, notes, and snippets.

@webinfinita
Last active August 29, 2015 14:17
Show Gist options
  • Save webinfinita/a06280e369b8b24916b4 to your computer and use it in GitHub Desktop.
Save webinfinita/a06280e369b8b24916b4 to your computer and use it in GitHub Desktop.
Abstract Mailer class for Laravel 5
<?php namespace App\Services\Mailers;
abstract class Mailer {
public function sendTo($user, $subject, $view, $data = [])
{
Mail::queue($view, $data, function($message) use ($user, $subject)
{
$message->to($user->email)->subject($subject);
});
}
}
<?php namespace App\Services\Mailers;
class UserMailer extends Mailer {
public function welcome()
{
$view = 'emails.welcom';
$data = [];
$subject = 'Welcome to App';
return $this->sendTo($user, subject, $view, $data);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment