Chatify Laravel Package
repository·master·Indexed 25 days ago
https://github.com/munafio/chatifyA comprehensive real-time one-to-one chatting system for Laravel applications. It provides a responsive chat UI with features including typing indicators, message seen indicators, attachment uploads, emoji support, and dark mode. The package integrates with Pusher for real-time events and includes the ChatifyMessenger service for managing messages, conversations, user favorites, and configuration settings.
What's inside Chatify
- Chatify is a real-time, one-to-one chatting system designed for Laravel applications. It allows developers to integrate a complete chat interface into new or existing Laravel projects with minimal effort. Key features include real-time contact updates, typing indicators, message seen indicators, attachment uploads (photos/files), emoji support, and a responsive UI with dark mode and chat customization.
Re-publish Chatify assets for v1.2.4 and higher
masterWhen upgrading to version 1.2.4 or higher, use the dedicated
chatify:publishcommand to update your project's assets.Warning: Using the
--forceflag will overwrite all existing assets (views, assets, config, etc.), meaning any custom modifications you have made to these files will be lost.Publish Chatify assets and configuration
masterChatify allows you to publish its various components (config, migrations, models, controllers, views, assets, and routes) to your Laravel application so you can customize them. You can use the
--tagflag with thevendor:publishcommand to publish specific groups of files.Available tags:
chatify-config: Thechatify.phpconfiguration file.chatify-migrations: Database migrations for users and chat tables.chatify-models: Chatify models.chatify-controllers: Chatify controllers.chatify-views: Chatify Blade views.chatify-assets: CSS, JS, images, and sounds.chatify-routes: Chatify route files.
Install Chatify via Artisan CLI
masterTo install the Chatify package into your Laravel application, run the
chatify:installArtisan command. This command automates the following setup steps:- Configuration: Publishes the
chatify.phpconfig file. - Views: Publishes Chatify views to
resources/views/vendor/Chatify. - Assets: Publishes CSS and JS assets to
public/css/chatify. - Models: Publishes the
ChMessage.phpmodel. - Migrations: Publishes the database migrations required for the messages table.
- Routes: Publishes the Chatify routes.
- Storage: Automatically runs
storage:linkto ensure file uploads/storage work correctly.
Note on Overwriting: If any of the files above already exist in your project, the command will prompt you for permission to overwrite them. By default, it will not overwrite existing files unless you confirm.
- Configuration: Publishes the
Configure the default user avatar
masterChatify uses an
avatarcolumn on theuserstable to store user profile images. When a user does not have a custom avatar, the system defaults to the value defined in your Chatify configuration.You can set this default value by updating the
user_avatar.defaultkey in yourconfig/chatify.phpfile.Configure Chatify routes
masterChatify's routes can be customized via the
chatify.phpconfiguration file.By default, Chatify loads its internal routes. However, if you set
chatify.routes.customtotruein your configuration, Chatify will instead look for route files in your application'sroutes/chatify/directory (web.phpandapi.php).You can also customize the following route settings in the config:
chatify.routes.prefix: The URL prefix for web routes.chatify.routes.namespace: The controller namespace for web routes.chatify.routes.middleware: Middleware applied to web routes.chatify.api_routes.prefix: The URL prefix for API routes.chatify.api_routes.namespace: The controller namespace for API routes.chatify.api_routes.middleware: Middleware applied to API routes.
Update user settings and status
masterCustomize the messenger experience and user presence:
- Update Settings:
updateSettingsallows changingdark_mode(passdarkor other values),messengerColor, and updating the user'savatarfile. - Set Active Status:
setActiveStatusupdates the user's online/offline presence. Passstatus: 1for active and0for inactive.
- Update Settings:
Search for users in messenger
masterSearch for users by name using the
searchendpoint.Request Parameters:
input: The search string (trimmed and filtered).per_page(optional): Number of results per page (defaults to 30).
Response Format: Returns a JSON object containing:
records: A string of HTML containing the search results (usingChatify::layouts.listItem).total: Total matching users.last_page: The last page number.- If no results are found,
recordsreturns:<p class="message-hint center-el"><span class='Nothing to show.</span></p>.
Download message attachments
masterRetrieve a downloadable URL for a file attachment using thedownloadendpoint. Provide thefileNameas a parameter. If the file exists in the configured Chatify attachment folder, the API returns the file name and its storage URL.Access file attachments and user avatars via storage
masterChatify uses Laravel's Storage facade to manage files. You can retrieve URLs for attachments and avatars using the following methods:
getAttachmentUrl($attachment_name): Returns the URL for a specific attachment file.getUserAvatarUrl($user_avatar_name): Returns the URL for a user's avatar.storage(): Returns the Laravel Storage instance configured viachatify.storage_disk_name.
Delete conversations and messages
masterRemove chat data via the following endpoints:
deleteConversation: Deletes the entire conversation for the providedid. Returns JSON{"deleted": 1}or{"deleted": 0}.deleteMessage: Deletes a specific message by itsid. Returns JSON{"deleted": 1}or{"deleted": 0}.
Manage favorites
masterToggle or retrieve favorite contacts.
Toggle Favorite (
favoriteendpoint):- Request Parameter:
user_id(the ID of the user to favorite/unfavorite). - Behavior: If the user is already a favorite, they are removed; otherwise, they are added.
- Response: JSON with
status(1 for added, 0 for removed).
Get Favorites List (
getFavoritesendpoint):- Response: JSON containing:
count: Total number of favorites.favorites: HTML string of the favorites list (usingChatify::layouts.favorite). If empty, returns0.
- Request Parameter: