Skip to content

Instantly share code, notes, and snippets.

@renepardon
Created October 2, 2017 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renepardon/0086ca7a091acd5dffa72e6e229f0a69 to your computer and use it in GitHub Desktop.
Save renepardon/0086ca7a091acd5dffa72e6e229f0a69 to your computer and use it in GitHub Desktop.
<?php
namespace App\Listeners\Trainer;
use App\Event\UserRegistered;
use App\I18nTrait;
use App\Mail\Trainer\Welcome;
use Illuminate\Config\Repository as Config;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailer;
use Illuminate\Queue\InteractsWithQueue;
/**
* Class SendWelcomeMail
*
* @package App\Listeners
*/
class SendWelcomeMail implements ShouldQueue
{
use InteractsWithQueue, I18nTrait;
/**
* @var UserRegistered
*/
public $event;
/**
* @var Config
*/
protected $config;
/**
* @var Mailer
*/
protected $mailer;
/**
* @param Config $config
*/
public function __construct(Config $config, Mailer $mailer)
{
$this->config = $config;
$this->mailer = $mailer;
}
/**
* @param UserRegistered $event
*
* @return void
*/
public function handle(UserRegistered $event)
{
$this->event = $event;
$this->setUserLocale($this->event->user->flag->interface_language);
$this->mailer->to($this->event->user->email)
->send(new Welcome($this->event->user));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment