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?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Ff0WJH
via IFTTT

Aucun commentaire:

Enregistrer un commentaire