Aaron
Aaron

Reputation: 4480

Laravel Notifications System: method notify does not exist.

I created a notification system and I am trying to to use the notify method to send a message. Instead, I am getting

Method notify does not exist.

I included at the top of my Controller use Notifications\EmailClientOfAccount;. Here is my code. I can include more if that will be helpful.

foreach ($emails as $email){
                $client = User::where('email', $email)->get();
                $notificationOptions = EmailClientOfAccount::sendEmailToClient($email, $user);
                $client->notify(new EmailClientOfAccount($notificationOptions));
            }

Upvotes: 0

Views: 1194

Answers (1)

Marcin Nabiałek
Marcin Nabiałek

Reputation: 111839

Make sure in your User model you imported Notifiable trait

After class, you should have something like this:

class User ... {

   use \Illuminate\Notifications\Notifiable;

to make Laravel trait imported. This trait use 2 other traits and in \Illuminate\Notifications\RoutesNotifications there is notify method that you want to use.

Upvotes: 1

Related Questions