Last active
August 29, 2015 14:17
-
-
Save webinfinita/a06280e369b8b24916b4 to your computer and use it in GitHub Desktop.
Abstract Mailer class for Laravel 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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