Created
August 31, 2016 17:50
-
-
Save rudiedirkx/572462c1b96b0353431918a709630fe2 to your computer and use it in GitHub Desktop.
User invitation jobs
This file contains hidden or 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 | |
| class SendUserInvitationJob { | |
| protected $user; | |
| protected $tests; | |
| function __construct(User $user, array $tests) { | |
| $this->user = $user; | |
| $this->tests = $tests; | |
| } | |
| function handle(Mailer $mailer) { | |
| $mailer->sendTo($this->user, 'invitation'); | |
| } | |
| } |
This file contains hidden or 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 | |
| class SendUserInvitationReminderJob extends SendUserInvitationJob { | |
| function handle(Mailer $mailer) { | |
| $mailer->sendTo($this->user, 'invitation reminder'); | |
| } | |
| } |
This file contains hidden or 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 | |
| class UserController { | |
| function postCreate(Queue $queue) { | |
| $user = new User; | |
| $tests = [new Test, new Test]; | |
| $queue->dispatch(new SendUserInvitationJob($user, $tests)); // instantly | |
| $queue->dispatch((new SendUserInvitationReminderJob($user, $tests))->delay('1 week')); // later | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment