Advertisement
Guest User

Untitled

a guest
May 21st, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.55 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Notifications;
  4.  
  5. use Illuminate\Bus\Queueable;
  6. use Illuminate\Notifications\Notification;
  7. use Illuminate\Contracts\Queue\ShouldQueue;
  8. use Illuminate\Notifications\Messages\MailMessage;
  9. use App\Models\User;
  10.  
  11. class UserCreated extends Notification
  12. {
  13.     use Queueable;
  14.  
  15.     private $user;
  16.  
  17.     /**
  18.      * Create a new notification instance.
  19.      *
  20.      * @return void
  21.      */
  22.     public function __construct(User $user)
  23.     {
  24.         $this->user = $user;
  25.         $this->url = route("activation.verify", ['token' => $user->email_token]);
  26.     }
  27.  
  28.     /**
  29.      * Get the notification's delivery channels.
  30.      *
  31.      * @param  mixed  $notifiable
  32.      * @return array
  33.      */
  34.     public function via($notifiable)
  35.     {
  36.         return ['mail'];
  37.     }
  38.  
  39.     /**
  40.      * Get the mail representation of the notification.
  41.      *
  42.      * @param  mixed  $notifiable
  43.      * @return \Illuminate\Notifications\Messages\MailMessage
  44.      */
  45.     public function toMail($notifiable)
  46.     {
  47.         return (new MailMessage)
  48.                     ->greeting(sprintf("Hello %s", $this->user->first_name))
  49.                     ->line('Your account has been created.')
  50.                     ->action('Activate Account', $this->url)
  51.                     ->line('Thank you for using our application!');
  52.     }
  53.  
  54.     /**
  55.      * Get the array representation of the notification.
  56.      *
  57.      * @param  mixed  $notifiable
  58.      * @return array
  59.      */
  60.     public function toArray($notifiable)
  61.     {
  62.         return [
  63.             //
  64.         ];
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement