Laravel 5.6 - 模型事件:你可以将static :: creation和static :: updates组合在一起吗?

I have model events:

protected static function boot()
{
    parent::boot();

    static::creating(function ($questionnaire) {
        // Same code here
    });

    static::updating(function ($questionnaire) {
        // Same code here
    });
}

Is there a way of combining creating and updating together or is it better to put the same code in some sort of partial to reuse in each event?

https://laravel.com/docs/5.6/eloquent#events

When a new model is saved for the first time, the creating and created events will fire. If a model already existed in the database and the save method is called, the updating / updated events will fire. However, in both cases, the saving / saved events will fire.

The saving event is fired when a model is being created or being updated.