cmgmyr / laravel-messenger

Simple user messaging package for Laravel
MIT License
2.46k stars 517 forks source link

Messagable::threads() does not respect soft deletes - so how do I truly remove a participant? #379

Closed cmgmyr closed 2 years ago

cmgmyr commented 2 years ago

Discussed in https://github.com/cmgmyr/laravel-messenger/discussions/376

Originally posted by **cyrillkalita** December 26, 2021 Could be a silly question, really, but `BelongsToMany` does not account for `SoftDeletes`. So a test structured like this, fails: - create a thread, - add a user participant to a thread - remove user participant using `removeParticipant()` The pivot attribute deleted_at is populated, as expected. so: 1. thread->participants()-count() is 0, as expected, but 2. $user->threads()->count() still returns 1, because this is how `BelongsToMany` works I read #205 and cannot help but wonder: am I missing something obvious?