我有模型事件:
protected static function boot()
{
parent::boot();
static::creating(function ($questionnaire) {
// Same code here
});
static::updating(function ($questionnaire) {
// Same code here
});
}
Run Code Online (Sandbox Code Playgroud)
是否有将创建和更新结合在一起的方法,还是将相同的代码放在某种局部中以便在每个事件中重用更好?