我收到这个错误,该怎么办?找不到我错过的东西。
未定义的功能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!");
}
}
谢谢!!
notify
是Notifiable
特性的一个方法,而且您不能从DB查询中调用notify,您应该使用Eloquent Model您需要将Notifiable
添加到您的User
型号中
示例:
$user = User::whereIn('role',['athlete'])
->where('contact_number', 'some value')
->get();
$user->each->notify(new SendSMS());
我希望这对有帮助