{"id":19943919,"url":"https://github.com/akiyamasm/messager","last_synced_at":"2025-04-09T08:12:05.060Z","repository":{"id":56990806,"uuid":"77855977","full_name":"akiyamaSM/messager","owner":"akiyamaSM","description":"A convenient way to handle messages between users in a simple way","archived":false,"fork":false,"pushed_at":"2019-10-08T10:07:26.000Z","size":42,"stargazers_count":153,"open_issues_count":6,"forks_count":17,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-02T06:07:38.660Z","etag":null,"topics":["convenient","laravel","messaging"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akiyamaSM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-02T19:14:15.000Z","updated_at":"2024-05-06T17:35:13.000Z","dependencies_parsed_at":"2022-08-21T12:50:48.831Z","dependency_job_id":null,"html_url":"https://github.com/akiyamaSM/messager","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akiyamaSM%2Fmessager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akiyamaSM%2Fmessager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akiyamaSM%2Fmessager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akiyamaSM%2Fmessager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akiyamaSM","download_url":"https://codeload.github.com/akiyamaSM/messager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247999864,"owners_count":21031046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["convenient","laravel","messaging"],"created_at":"2024-11-13T00:18:29.407Z","updated_at":"2025-04-09T08:12:05.019Z","avatar_url":"https://github.com/akiyamaSM.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"(NOT MAINTAINED)\n# Laravel Messager\nA convenient way to handle messages between users in a simple way\n\n__Table of Contents__\n\n1. [Installation](#installation)\n2. [Setup a Model](#setup-a-model)\n3. [Creating \u0026 Sending Messages](#creating--sending-messages)\n    1. [Creating a message](#creating-a-message)\n    2. [Sending the message](#sending-the-message)\n    3. [Responding the message](#responding-the-message)\n    4. [Drafting a message](#drafting-a-message)\n4. [Working with Messages](#working-with-messages)\n    1. [Getting messages between users](#getting-messages-between-users)\n    2. [Read messages](#read-messages)\n    3. [Unread messages](#unread-messages)\n    4. [Draft messages](#draft-messages)\n5. [Tags](#tags)  \n    1. [Create and Edit tags](#create-and-edit-tags)\n    2. [Assign tag to message](#assign-tag-to-message)\n    3. [Change and get tag of a message](#change-and-get-tag-of-a-message)\n    4. [Remove a tag from a message](#remove-a-tag-from-a-message)\n\n## Installation:\nFirst, install the package through Composer.\n\n```php\ncomposer require inani/messager\n```\n\nThen include the service provider inside `config/app.php`.\n\n```php\n'providers' =\u003e [\n    ...\n    Inani\\Messager\\MessagerServiceProvider::class,\n    ...\n];\n```\nPublish config and migrations\n\n```\nphp artisan vendor:publish\n```\n\n___\n\n## Setup a Model\n\nTo setup a model all you have to do is add (and import) the `MessageAccessible` trait.\n\n```php\nuse Inani\\Messager\\Helpers\\MessageAccessible;\nuse Inani\\Messager\\Helpers\\TagsCreator;\nclass User extends Model\n{\n    use MessageAccessible, TagsCreator;\n    ...\n}\n```\n\n___\n\n## Creating \u0026 sending Messages\n\n### Creating a message\n```php\n$receiver = User::find(1); \n\n// Message Data\n$messageData = [\n\t'content' =\u003e 'Hello all this is just a test', // the content of the message\n\t'to_id' =\u003e $receiver-\u003egetKey(), // Who should receive the message\n];\n\nlist($message, $user) = App\\User::createFromRequest($messageData);\n```\n\n### Sending the message\n```php\n$sender = User::find(2);\n\n$sent = $sender-\u003ewrites($message)\n                 -\u003eto($user)\n                 -\u003esend();\n\t\t \n// send to multiple users the same message\n// can execpt a user|array of users| array of ids| or array of users and ids\n$sent = $sender-\u003ewrites($message)\n                 -\u003eto($user)\n\t\t -\u003ecc([$user1, $user2])\n\t\t -\u003ecc([$user3-\u003eid, $user4-\u003eid])\n                 -\u003esend();\n```\n\n### Responding the message\n```php\n$sender = User::find(2);\n\n$sent = $user-\u003ewrites($newMessage)\n                 -\u003eto($sender)\n\t\t -\u003eresponds($message)\n                 -\u003esend();\n```\n\n### Drafting a message\n```php\n$sender = User::find(2);\n\n$draft = $sender-\u003ewrites($message)\n                  -\u003eto($user)\n                  -\u003edraft()\n                  -\u003ekeep();\n```\n\n___\n## Working with Messages\nOnce you've got messages you need to do something with them. \n\n\n### Getting messages between users\n```php\n// Users\n$userA = App\\User::find(1);\n$userB = App\\User::find(2);\n\n// Get seen messages sent from UserB to UserA\n$messages = $userA-\u003ereceived()-\u003efrom($userB)-\u003eseen()-\u003eget();\n\n// OR you can pass an array of IDs \n$messages = $userA-\u003ereceived()-\u003efrom([2, 3, 4, 5])-\u003eseen()-\u003eget();\n```\n### Read messages\n```php\n// Set the selected message(or id of messages as read)\n$count = $userB-\u003ereceived()-\u003eselect($message)-\u003ereadThem();\n\n```\n### Unread messages\n```php\n// Get unread messages from UserB to User A\n$messages = $userA-\u003ereceived()-\u003efrom($userB)-\u003eunSeen()-\u003eget();\n\n// Marking them as read\n$messages = $userA-\u003ereceived()-\u003efrom($userB)-\u003eunSeen()-\u003ereadThem();\n\n// check out if a conversation has new messages\n$bool = $userA-\u003ereceived()-\u003econversation($message)-\u003ehasNewMessages();\n\n// Get the number of conversations that have new messages in it\n$number = $userA-\u003ereceived()-\u003eunSeenConversations();\n```\n\n### Sent messages\n```php\n// Get unread messages from UserA to UserB\n$messages = $userA-\u003esent()-\u003eto($userB)-\u003eget();\n\n// OR you can pass an array of IDs\n$messages = $userA-\u003ereceived()-\u003eto([2, 3, 4, 5)-\u003eget();\n```\n\n### Draft messages\n```php\n// Get the draft messages for UserA\n$messages = $userA-\u003esent()-\u003einDraft()-\u003eget().\n```\n## Tags\nYou can tag (or structure your messages in different categories).\n\n### Create and Edit tags\neach user can make any number of tags.\n```php\n// create a new tag, $data can be (Tag instance, array, Request)\n$tag = $userA-\u003eaddNewTag($data);\n\n// Modify the attributes of a tag\n$user-\u003etag($tag)-\u003ename(\"social\")-\u003ecolor(\"#ffff\")-\u003eapply();\n\n```\n### Assign tag to message\nOnce you have the message and the tag\n```php\n// you'll need the instance of user(to check if sender or receiver)\n// $user and $tag can be ids or instance of User, Tag classes\n$bool = $message-\u003econcerns($user)-\u003eputTag($tag);\n```\n### Change and get tag of a message\n```php\n// to change the tag just use the same method\n$bool = $message-\u003econcerns($user)-\u003eputTag($tag);\n\n// to get the tag of the message, null if not tagged\n$tagOrNull = $message-\u003econcerns($user)-\u003egetTag();\n// \n```\n\n### Remove a tag from a message\n```php\n// To remove the tag from the message\n$bool = $message-\u003econcerns($user)-\u003eremoveTag();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakiyamasm%2Fmessager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakiyamasm%2Fmessager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakiyamasm%2Fmessager/lists"}