messenger icon indicating copy to clipboard operation
messenger copied to clipboard

When a new thread is created, there is no participants_count value set

Open Sandbird opened this issue 4 months ago • 0 comments

When a new thread is created (adding 2 users for testing), this value 'participants_count' is not set. (=> $thread->participants()->count())

Image

If I refresh the page though, then I get this information. The participants_count is still missing, but i can use the data.resources.participants.meta.total value.

Image

Not sure how else to retrieve the value, but in order to do it I added, in rtippin\messenger\src\Models\Thread.php:

    /**
     * Get the participants count directly
     *
     * @return int
     */
    public function getParticipantsCountAttribute(): int
    {
        return $this->participants()->count();
    }

and then in rtippin\messenger\src\Http\Resources\ThreadResource.php, right after 'latest_message' => $this->addRecentMessage(), i added: 'participants_count' => $this->getParticipantsCountAttribute(),

Sandbird avatar Aug 04 '25 16:08 Sandbird