在字符串上调用成员函数 notify()
Call to a member function notify() on string
'我是 Laravel 的新手,我正在尝试发送通知,但它显示错误(调用字符串上的成员函数 notify())'
$discussion->user['email']->notify(new newReplyAdded($discussion));
您需要在模型上使用 notify(),而不是在字符串上。喜欢下面
$user = User::find(1);
$user->notify(..)
而且你必须在你的模型中使用 Notifiable trait
use Illuminate\Notifications\Notifiable;
class User extends Model
{
use Notifiable;
..........
}
对于你的情况,你可以试试这个
$discussion->user->notify(new newReplyAdded($discussion));
'我是 Laravel 的新手,我正在尝试发送通知,但它显示错误(调用字符串上的成员函数 notify())'
$discussion->user['email']->notify(new newReplyAdded($discussion));
您需要在模型上使用 notify(),而不是在字符串上。喜欢下面
$user = User::find(1);
$user->notify(..)
而且你必须在你的模型中使用 Notifiable trait
use Illuminate\Notifications\Notifiable;
class User extends Model
{
use Notifiable;
..........
}
对于你的情况,你可以试试这个
$discussion->user->notify(new newReplyAdded($discussion));