1

in laravel 5.3 I use notifications to send mail and save notification to user whenever a successful registration. I create Register extends Notification have ToEmail, ToArray

public function toMail($notifiable){
   return (new MailMessage)
                ->line('The introduction to the notification.')
                ->action('Notification Action', 'https://laravel.com'.print_r($notifiable, true))
                ->line('Thank you for using our application!');
    }
public function toArray($notifiable){
        return [
            'data' => 'A new post was published on Laravel News.'
        ];
    }

And in model Use I write function

public function routeNotificationForMail(){
        return $this->email;
    }
public function routeNotificationForDatabase(){
        Log::info('run route database');
        return $this;
 }

Instruction table User(id, email, password) table Notifications (id, type, notifiable_id, notifiable_type, data, read_at) But when register I only email while notification not insert to table.

Update

Thank you @ABDEL-RHMAN, but I set via method to return ['database','mail'] because I can send email notification but not insert to table. I have a solution ? Thank all

deverlop php
  • 41
  • 1
  • 6

0 Answers0