【发布时间】:2021-09-27 18:03:44
【问题描述】:
我正在使用 Laravel 通知,如果我编写插入查询,我想将数据保存在我的数据库表中,然后我会收到以下错误,否则通知正在运行:
TypeError: App\User::getLogNameToUse() 的返回值必须是 输入字符串,null
这是查询
public function toMail($notifiable)
{
$users = User::find($notifiable->id);
$users->verification_link=$link;
$users->save();
...
...
}
型号:
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use App\Notifications\ResetPasswordNotification;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Spatie\Activitylog\Traits\LogsActivity;
class User extends Authenticatable
{
use Notifiable, LogsActivity;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'role_id', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
public function role()
{
return $this->belongsTo(Models\Role::class);
}
}
【问题讨论】:
-
检查
getLogNameToUse方法是否存在于您可能正在扩展的模型、特征或父类中 -
@MikeRoss:不,没有方法
getLogNameToUse,我正在使用 spatie 包进行日志管理 -
你可以添加你的用户模型代码吗?
-
@MikeRoss:添加型号代码请检查,Spatie 包链接:spatie.be/docs/laravel-activitylog/v1/advanced-usage/…
-
给你一个错误 this 部分包代码。你有没有从
config/activityLog文件中修改过任何东西??特别是default_log_name?
标签: laravel laravel-5 laravel-4