* @author Ryan Thompson */ class UserHasRegistered extends Notification implements ShouldQueue { use Queueable; /** * The user who registered. * * @var UserInterface */ public $user; /** * Create a new UserHasRegistered instance. * * @param UserInterface $user */ public function __construct(UserInterface $user) { $this->user = $user; } /** * Get the notification's delivery channels. * * @return array */ public function via() { return ['mail', 'slack']; } /** * Return the mail message. * * @param AnonymousNotifiable $notifiable * @return MailMessage */ public function toMail(AnonymousNotifiable $notifiable) { $data = $this->user->attributesToArray(); return (new MailMessage()) ->view('anomaly.module.users::notifications.user_has_registered') ->subject(trans('anomaly.module.users::notification.user_has_registered.subject', $data)) ->line(trans('anomaly.module.users::notification.user_has_registered.instructions', $data)) ->action( trans('anomaly.module.users::notification.user_has_registered.button', $data), $this->user->route('view') ); } /** * Return the slack message. * * @param UserInterface $notifiable * * @return SlackMessage */ public function toSlack(UserInterface $notifiable) { return (new SlackMessage()) ->success() ->content('Hmm.. What\'s Ryan up to?') ->attachment( function ($attachment) { $attachment ->title('Testing out teh goodies!', 'http://pyrocms.com/') ->fields( [ 'Username' => $this->user->getUsername(), 'Eamil' => $this->user->getEmail(), ] ); } ); } /** * Return the array storage data. * * @param Notifiable $notifiable * * @return array */ public function toDatabase(UserInterface $notifiable) { return [ 'user' => $this->user, ]; } }