mercredi 25 avril 2018

Laravel 5.6 - Model events: Can you combine static::creating and static::updating on one?

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?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire