RenderFooterEvent
RenderFooterEvent is dispatched while NexoPOS renders the dashboard footer. Modules can listen to this event and append custom footer output, usually scripts, markup, or a Blade view that must be available when the page finishes loading.
When The Event Runs
NexoPOS dispatches this event from the footer injection view when the current request has a Laravel route. The current route name is passed to the event, so listeners can decide whether their footer content should be injected on every page or only on a specific page.
Available Properties
$event->output: anApp\Classes\Outputinstance used to append rendered content.$event->routeName: the current route name, ornullwhen no route name is available.
Listen From A Module
A module can register a listener by creating a listener class inside its Listeners directory, for example RenderFooterEventListener. The listener receives the event instance through its handle() method.
<?php
namespace Modules\MyModule\Listeners;
use App\Events\RenderFooterEvent;
class RenderFooterEventListener
{
public function handle( RenderFooterEvent $event )
{
$event->output->addView( 'MyModule::footer.scripts' );
}
}
Listen With Event::listen
The event can also be registered directly with Laravel's Event::listen() method. This is useful when the listener is registered from a service provider or another bootstrapping class.
use App\Events\RenderFooterEvent;
use Illuminate\Support\Facades\Event;
Event::listen( RenderFooterEvent::class, function ( RenderFooterEvent $event ) {
$event->output->addView( 'MyModule::footer.scripts' );
} );
Limit Injection To A Route
When the footer content is only needed on one screen, check $event->routeName before adding the view. This keeps module assets and markup away from pages that do not need them.
Event::listen( RenderFooterEvent::class, function ( RenderFooterEvent $event ) {
if ( $event->routeName !== 'ns.dashboard.orders.index' ) {
return;
}
$event->output->addView( 'MyModule::orders.footer' );
} );
Injecting The View
Use $event->output->addView( 'ModuleNamespace::path.to.file' ) to append a Blade view to the footer output. The view path must be resolvable by Laravel using the module's registered view namespace.
$event->output->addView( 'ModuleNamespace::path.to.file' );
Summary
- Use
RenderFooterEventwhen a module needs to inject footer output after a page has loaded. - Add content through
$event->output, usually withaddView(). - Use
$event->routeNamewhen the injection should apply only to specific dashboard pages.