在我的laravel项目中,我在我的用户模型中使用Updater来输入created_by,updated_by和deleted_by.it适用于所有操作,但显示resetpassword的错误。错误
Updater.php第13行中的ErrorException:尝试获取属性 非对象
Updater.php
<?php
namespace App;
use Auth;
trait Updater { protected static function boot() {
parent::boot(); /* * During a model create Eloquent will also update the updated_at field so * need to have the updated_by field here as well * */
static::creating(function($model) { $model->created_by = Auth::user()->id;
$model->updated_by = Auth::user()->id;
});
static::updating(function($model) {
$model->updated_by = Auth::user()->id;
});
/*
* Deleting a model is slightly different than creating or deleting. For
* deletes we need to save the model first with the deleted_by field
* */
static::deleting(function($model) {
$model->deleted_by = Auth::user()->id;
$model->save();
});
}
}