Laravel通知频道



我收到这个错误,该怎么办?找不到我错过的东西。

未定义的功能App\Console\Commands\Notify

这是命令:

public function handle()
{
$user = DB::table('users')
->whereIn('role',['athlete'])
->andWhere('contact_number');
$user = notify(new SendSMS);
}
}

通知:

public function via($notifiable)
{
return [TwilioChannel::class];
}
public function toTwilio($notifiable)
{
return (new TwilioSmsMessage())
->content("Hi {$notifiable->first_name}. Your account was approved!");
}
}

谢谢!!

notifyNotifiable特性的一个方法,而且您不能从DB查询中调用notify,您应该使用Eloquent Model您需要将Notifiable添加到您的User型号中

示例:

$user = User::whereIn('role',['athlete'])
->where('contact_number', 'some value')
->get();
$user->each->notify(new SendSMS());

我希望这对有帮助

最新更新