mercredi 9 mars 2016

Laravel set/modify Model attribute during trait boot

Is it possible for a trait's boot method to set or modify a Model's attribute? The following non-working example illustrates what I am going for:

trait MyTrait {

    public static function bootMyTrait(){
        static::creating(function(Model $item){
            $item->foo = 'foo';
        });
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire