hotwired-laravel / turbo-laravel

This package gives you a set of conventions to make the most out of Hotwire in Laravel.
https://turbo-laravel.com
MIT License
803 stars 50 forks source link

Ensure recently created models are broadcasted to the plural of the model name #62

Closed tonysm closed 2 years ago

tonysm commented 2 years ago

Recently there was an interesting issue and PR sent to turbo-rails questioning why when creating a model the broadcast is sent to that model's channel by default (when using the vanilla protected $broadcasts = true approach) because since the model was just created, no one is listening to that channel.

The change made was that, by default, we should broadcast to the model's plural channel instead. I'm not sure yet how to approach this here.

Suggestion: ensure broadcasting newly created models when using the vanilla protected $broadcasts = true approach is sent to a private channel using the model's pluralized base name.