MoonShine MoonShine
EN
← All plugins

Rush

Made by the authors of MoonShine
Supports dark mode
Multilingualism

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.

Rating
Downloads
52
Version
-
Last updated
-
MoonShine version
v3, v2
Github stars
2
2000.00 ₽ 8000.00 ₽
  • Проверено MoonShine
  • Приоритетная тех. поддержка

Rush

Laravel required PHP required MoonShine required

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

  1. Install the package via Composer:

    composer require moonshine/rush
    composer require moonshine/rush
  2. Publish assets, configuration, and WebSocket application code samples:

    php artisan moonshine-rush:install
    php artisan moonshine-rush:install
  3. If you're using notifications from this package, replace MoonShineNotificationContract in your service provider:

    $this->app->bind(MoonShineNotificationContract::class, RushNotificationAdapter::class);
    $this->app->bind(MoonShineNotificationContract::class, RushNotificationAdapter::class);

Usage

Notifications

Attach the HasRushNotifications trait to your MoonShineLayout:

final class MoonShineLayout extends CompactLayout
{
use HasRushNotifications;
// ...
}
final class MoonShineLayout extends CompactLayout
{
use HasRushNotifications;
// ...
}

FormPage

To display active users on the form page, attach the HasRushForm trait to your resource:

use HasRushForm;
use HasRushForm;

FragmentReload

Enable fragment reloading on Alpine events:

FragmentWs::make([
FlexibleRender::make("Test reload " . time()),
])
->name('metrics');
FragmentWs::make([
FlexibleRender::make("Test reload " . time()),
])
->name('metrics');

Trigger a fragment reload from the server:

FragmentReload::send('metrics');
FragmentReload::send('metrics');

For private channels:

FragmentWs::make([
FlexibleRender::make("Test reload " . time()),
])
->privateChannel()
->name('metrics');
 
// Sending event to a specific user
FragmentReload::send('metrics', userId: 1);
FragmentWs::make([
FlexibleRender::make("Test reload " . time()),
])
->privateChannel()
->name('metrics');
 
// Sending event to a specific user
FragmentReload::send('metrics', userId: 1);

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
  • now_on_form_channel: Prefix for form channels
  • fragment_reload_channel: Prefix for fragment reload channels

Connection

Frontend

Initialize the connection after the moonshine:init event:

document.addEventListener("moonshine:init", () => {
// Your initialization code here
})
document.addEventListener("moonshine:init", () => {
// Your initialization code here
})

Pass all channel events to the MoonShine.onCallback('onMoonShineWS') function:

// Echo example
MoonShine.onCallback('onMoonShineWS', function(channel, onPublic) {
window.Echo.private(channel)
.listen('.moonshine.ws.event', (e) => {
onPublic(e)
}).subscribed(() => {
 
 
document.dispatchEvent(new CustomEvent('rush-subscribe:' + channel))
})
})
// Echo example
MoonShine.onCallback('onMoonShineWS', function(channel, onPublic) {
window.Echo.private(channel)
.listen('.moonshine.ws.event', (e) => {
onPublic(e)
}).subscribed(() => {
 
 
document.dispatchEvent(new CustomEvent('rush-subscribe:' + channel))
})
})

Trigger the moonshine:rush event after connecting:

window.Echo.connector.pusher.connection.bind('connected', () => {
document.dispatchEvent(new CustomEvent('moonshine:rush'))
})
window.Echo.connector.pusher.connection.bind('connected', () => {
document.dispatchEvent(new CustomEvent('moonshine:rush'))
})

Backend

Implement the RushBroadcastContract interface for server-side event sending:

final class SocketIO implements RushBroadcastContract
{
public function send(string $channel, RushData $rushData): void {
// Your implementation here
}
}
final class SocketIO implements RushBroadcastContract
{
public function send(string $channel, RushData $rushData): void {
// Your implementation here
}
}

Bind the implementation in your service provider:

$this->app->bind(RushBroadcastContract::class, SocketIO::class);
$this->app->bind(RushBroadcastContract::class, SocketIO::class);

License

Rush is a commercial software product distributed under a paid license. To use the package, you must purchase a license.

Purchasing a license

  1. Visit the official website moonshine-laravel.com.
  2. Make a payment through the available methods on the site.
  3. 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