anwar / laravel-support
Support conversations and messaging module
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/anwar/laravel-support
Requires
- php: ^8.1
- illuminate/broadcasting: ^10.0
- illuminate/database: ^10.0
- illuminate/queue: ^10.0
- illuminate/support: ^10.0
README
A lightweight, production-ready Laravel package that provides support conversations and messaging features (conversations, messages, agents, guests, assignments, reads and broadcasting support channels).
Table of Contents
Highlights β
- Conversation lifecycle: create, reply, assign, close
- Message read tracking and assignment history
- Guest support with configurable guards and rate-limits
- Built-in Broadcast channels and events for real-time UIs
- Policy-based authorization for agents and supervisors
- Auto-registers as a Laravel provider (PSR-4:
Anwar\\Support\\)
Requirements π§
- PHP >= 8.1
- Laravel 10.x (or compatible 10.x series)
- Illuminate components: database, broadcasting, queue, support
Installation π¦
For a published package on Packagist:
composer require anwar/laravel-support
For local development in a monorepo, add to your root composer.json:
"repositories": [ { "type": "path", "url": "packages/support" } ]
Then require the package (example for local dev):
composer require anwar/laravel-support:dev-main --prefer-source
The package supports Laravel's package auto-discovery. To register manually, add this to config/app.php providers:
Anwar\Support\SupportServiceProvider::class,
Publish config
php artisan vendor:publish --provider="Anwar\Support\SupportServiceProvider" --tag=support-config
Migrate database
The package loads its own migrations automatically. Run:
php artisan migrate
Configuration βοΈ
Configuration file: config/support.php
Key configuration options include:
table_prefixβ prefix for package tables (defaultsupport_)user_modelβ your User model classguardsβcustomerandagentguard settingsmiddlewareβ middleware groups for customer/agent APIsrolesβ agent and supervisor role namespermissionsβ permission namesview_inboxandview_allguest.enabledβ allow guest conversationsrate_limitsβ customer/guest per-minute messaging throttles
Adjust these with your application environment variables (see SUPPORT_*).
Usage π§
Routes / API
Routes are registered under the /support prefix (see src/Routes/api.php).
Customer-facing routes (middleware support.middleware.customer):
- POST
/support/conversationsβ Create a conversation - GET
/support/conversations/{conversation}β Show conversation - POST
/support/conversations/{conversation}/messagesβ Add a message (throttled) - POST
/support/conversations/{conversation}/readβ Mark as read - POST
/support/conversations/{conversation}/typingβ Typing indicator
Agent routes (middleware support.middleware.agent):
- GET
/support/agent/inboxβ Agent inbox - GET
/support/agent/conversations/{conversation}β Show conversation - POST
/support/agent/conversations/{conversation}/assignβ Assign conversation - POST
/support/agent/conversations/{conversation}/closeβ Close conversation - POST
/support/agent/conversations/{conversation}/noteβ Add internal note
Broadcast channels
Defined in src/Routes/channels.php:
support.conversation.{conversationId}β conversation updatessupport.user.{userId}β direct user notificationssupport.agentsβ agent/supervisor notifications
Authorization is delegated to Anwar\Support\Services\SupportAccess.
Events
The package emits events for your real-time frontend:
SupportConversationCreatedβ new conversationSupportMessageCreatedβ new messageSupportMessageReadβ message read updateSupportConversationAssignedβ conversation assignmentSupportConversationUpdatedβ conversation metadata/status updateSupportTypingβ typing on/off
Each event is broadcasted to relevant channelsβsubscribe on the client to update conversation lists and messages in real-time.
Models
Anwar\Support\Models\ConversationAnwar\Support\Models\MessageAnwar\Support\Models\ParticipantAnwar\Support\Models\ReadAnwar\Support\Models\AssignmentAnwar\Support\Models\Guest
Use the models directly or rely on the provided API controllers.
Testing & Development π§ͺ
- Run your application test suite from the project root (phpunit)
- For local development, you may want to configure the package as a path repository (see installation) and run
composer dump-autoloadafter changes
Good checks:
composer dump-autoload
php artisan migrate --seed
php artisan test
Contributing π€
Contributions are welcome.
- Fork the repo
- Create a feature branch
- Add tests for new behavior
- Send a pull request with a clear description
Please follow PSR-12 coding style and add unit/integration tests for new features.
License
MIT β see the LICENSE file.
Maintainers & Support
- Maintainer: ringkubd (repository owner)
- For issues and feature requests, please open an issue on the repository.
Base color for package branding:
#CE4631
If you'd like, I can also add examples for a JavaScript/Livewire front-end to consume the package's broadcasted events and realtime channels. π§