Astrotomic / laravel-translatable

A Laravel package for multilingual models
https://docs.astrotomic.info/laravel-translatable/
MIT License
1.23k stars 156 forks source link

Laravel dispatch events #239

Closed bajki closed 3 years ago

bajki commented 3 years ago

Hi, I want to use model events and it dosen't fire updated event on changed translated field.

So if i have field is_active and i change it, model fires event, but if i change translated name field it dosen't fire it.

Can you help me?

Gummibeer commented 3 years ago

Hey, the event fires on the translation model. So you have to listen to these events.

bajki commented 3 years ago

So how to create this?

Lets say i have this?

protected $dispatchesEvents = [ 'created' => ProjectCreated::class, 'updated' => ProjectUpdated::class, 'deleted' => ProjectDeleted::class, ];

protected $fillable = [ 'is_active']; protected $translatedAttributes = ['name', 'description'];

If i change name how to fire ProjectUpdated::class

Gummibeer commented 3 years ago

Hey, you should add the 'updated' => ProjectUpdated::class, to your ProjectTranslation model.

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days