Skip to content

Contacts not loading after page refresh: Undefined variable $lastMessage in listItem.blade.php #387

Description

@lokeshwardeb

Bug Report: Sidebar contacts are not loaded after page refresh (Undefined variable $lastMessage)

Hello @munafio and @contributors,

First of all, thank you for creating and maintaining this wonderful package.

While integrating Chatify into a Laravel application (not the demo project), I encountered an issue that prevents the contact list from loading correctly after refreshing the chat page.

Environment

  • Chatify: v1.6.3
  • Laravel: 11.x or upper
  • PHP: 8.5.x
  • MySQL: 8.x

Issue

After installing the package and opening the /chatify page, everything initially appears to work.

However, once the page is refreshed, the sidebar contact list is no longer loaded from the database. Existing conversations disappear from the sidebar.

Interestingly, if another user sends a new message, that conversation immediately appears again in the sidebar, which suggests that the real-time functionality is working, but the initial contact loading after a page refresh is not.

Error

During this process, the following error is thrown:

Undefined variable $lastMessage

The error originates from:

resources/views/vendor/Chatify/layouts/listItem.blade.php

Expected Behavior

  • Refreshing /chatify should load all existing conversations from the database.
  • The sidebar should display all contacts with their latest messages.
  • All required variables (including $lastMessage) should be passed correctly to listItem.blade.php.

Actual Behavior

  • The sidebar is empty after refreshing the page.
  • Existing conversations are not loaded.
  • $lastMessage is not available in listItem.blade.php, resulting in an Undefined variable $lastMessage exception.
  • It also appears that several other pieces of data expected by listItem.blade.php are missing, suggesting that the view is not receiving the required data during the contact-loading process.

Additional Notes

This issue occurs when using the Laravel package itself, not the official demo application.

As a temporary workaround, it is possible to modify the Blade views manually, but this only hides the symptoms rather than fixing the underlying problem. It seems that the required data is not being passed correctly before the view is rendered.

I would appreciate it if you could investigate this issue, as it affects the normal loading of conversations after a page refresh.

Thank you again for your work on this package.

Best regards,
Lokeshwar Deb Protik

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions