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
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
Issue
After installing the package and opening the
/chatifypage, 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:
The error originates from:
Expected Behavior
/chatifyshould load all existing conversations from the database.$lastMessage) should be passed correctly tolistItem.blade.php.Actual Behavior
$lastMessageis not available inlistItem.blade.php, resulting in anUndefined variable $lastMessageexception.listItem.blade.phpare 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