I am getting this error, what should i do? Can't really find what I miss.
Undefined function App\Console\Commands\Notify
Here is the command:
public function handle()
{
$user = DB::table('users')
->whereIn('role',['athlete'])
->andWhere('contact_number');
$user = notify(new SendSMS);
}
}
The notification:
public function via($notifiable)
{
return [TwilioChannel::class];
}
public function toTwilio($notifiable)
{
return (new TwilioSmsMessage())
->content("Hi {$notifiable->first_name}. Your account was approved!");
}
}
Thank you!!
CodePudding user response:
notify is a method of the Notifiable trait, also you cant call notify from the DB query you should use your Eloquent Model, also
you need to add Notifiable to your User model
Example :
$user = User::whereIn('role',['athlete'])
->where('contact_number', 'some value')
->get();
$user->each->notify(new SendSMS());
I hope it's helpful
