Chatify Laravel Package

repository·master·Indexed 25 days ago

https://github.com/munafio/chatify

A 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.

Tokens
3.7K
Snippets
0
Records
28
Agent score
82%

What's inside Chatify

  1. Overview of Chatify Laravel Package

    master
    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.
  2. Re-publish Chatify assets for v1.2.4 and higher

    master

    When upgrading to version 1.2.4 or higher, use the dedicated chatify:publish command to update your project's assets.

    Warning: Using the --force flag will overwrite all existing assets (views, assets, config, etc.), meaning any custom modifications you have made to these files will be lost.

  3. Publish Chatify assets and configuration

    master

    Chatify 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 --tag flag with the vendor:publish command to publish specific groups of files.

    Available tags:

    • chatify-config: The chatify.php configuration 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.
  4. Install Chatify via Artisan CLI

    master

    To install the Chatify package into your Laravel application, run the chatify:install Artisan command. This command automates the following setup steps:

    1. Configuration: Publishes the chatify.php config file.
    2. Views: Publishes Chatify views to resources/views/vendor/Chatify.
    3. Assets: Publishes CSS and JS assets to public/css/chatify.
    4. Models: Publishes the ChMessage.php model.
    5. Migrations: Publishes the database migrations required for the messages table.
    6. Routes: Publishes the Chatify routes.
    7. Storage: Automatically runs storage:link to 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.

  5. Configure Chatify routes

    master

    Chatify's routes can be customized via the chatify.php configuration file.

    By default, Chatify loads its internal routes. However, if you set chatify.routes.custom to true in your configuration, Chatify will instead look for route files in your application's routes/chatify/ directory (web.php and api.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.
  6. Search for users in messenger

    master

    Search for users by name using the search endpoint.

    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 (using Chatify::layouts.listItem).
    • total: Total matching users.
    • last_page: The last page number.
    • If no results are found, records returns: <p class="message-hint center-el"><span class='Nothing to show.</span></p>.
  7. Access file attachments and user avatars via storage

    master

    Chatify 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 via chatify.storage_disk_name.
  8. Manage favorites

    master

    Toggle or retrieve favorite contacts.

    Toggle Favorite (favorite endpoint):

    • 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 (getFavorites endpoint):

    • Response: JSON containing:
      • count: Total number of favorites.
      • favorites: HTML string of the favorites list (using Chatify::layouts.favorite). If empty, returns 0.