
Rush
Table of Contents
About
Rush is a powerful package that enables real-time event handling on web pages using WebSockets. It seamlessly integrates with Laravel and MoonShine admin panel to provide a robust solution for notifications, collaborative form editing, and dynamic content updates.
Features
- Real-time Notifications: Instantly receive and display notifications on the page.
- Collaborative Form Editing: Display active users on editing forms and track their actions in real-time.
- Dynamic Fragment Reload: Reload specific page fragments without a full page refresh.
- Flexible WebSocket Support: Compatible with various WebSocket applications:
- Laravel Echo (Pusher, Reverb)
- Centrifugo
- SocketIO
- Custom solutions
 
Installation
- 
Install the package via Composer: composer require moonshine/rushcomposer require moonshine/rush
- 
Publish assets, configuration, and WebSocket application code samples: php artisan moonshine-rush:installphp artisan moonshine-rush:install
- 
If you're using notifications from this package, replace MoonShineNotificationContractin your service provider:$this->app->bind(MoonShineNotificationContract::class, RushNotificationAdapter::class);$this->app->bind(MoonShineNotificationContract::class, RushNotificationAdapter::class);
- 
MoonShine Rush uses client-to-client message events, so if you're using Pusher, you need to enable Client Events in your application. 
Usage
Notifications
In MoonShineLayout use HasRushNotification trait:
If you haven't posted MoonShineLayout yet, do so:
Select Layout. Write the newly published Layout in the moonshine configuration file.
Sending a message is done using the Rush::events()->notification():
LiveForm
To display active users on the form page, attach the HasRushForm trait to your resource:
FragmentReload
Enable fragment reloading on Alpine events:
Trigger a fragment reload from the server:
For private channels:
HtmlReload
If you need to change the html code inside a block, for example <div id="container><p>HTML</p></div>, you can use HtmlReload.
First, you need to enable listening on the page by adding a new component.
Now we can update the container:
JsEvent
You can send any Js event using Rush:
The Rush::events()->js() method also accepts string type:
To send js events, you need to enable listening on the page by adding a new component:
Compatibility table
| Rush v1.x | Rush v2.x | 
|---|---|
| ✅ MoonShine v2.x | ✅ MoonShine v3.x | 
Configuration
The configuration file is located at config/moonshine_rush.php. Key options include:
- prefix: Prefix for all channels
- notifications_channel: Prefix for notification channels
- live_form_channel: Prefix for form channels
- fragment_reload_channel: Prefix for fragment reload channels
- html_reload: Prefix for html reload channels
Connection
Frontend
Initialize the connection after the moonshine:init event:
Pass all channel events to the MoonShine.onCallback('onMoonShineWS') function:
Trigger the moonshine:rush event after connecting:
Trigger the rush-subscribe event after subscribing:
Backend
Implement the RushBroadcastContract interface for server-side event sending:
Bind the implementation in your service provider:
License
Rush is a commercial software product distributed under a paid license. To use the package, you must purchase a license.
Purchasing a license
- Visit the official website moonshine-laravel.com.
- Make a payment through the available methods on the site.
- After successful payment, you will receive a personal license key.
Terms of Use
- The license is issued for one developer.
- The license gives the right to use the Rush package in commercial and non-commercial projects.
- Distribution or resale of the license key to third parties is strictly prohibited.
- Technical support and updates are provided in accordance with the terms of the purchased license.
For all questions related to licensing, please contact support: info@cutcode.dev
 
                             
                                 
                             
     
    