viewRenderEventManager add template with params

  • How can I inject a view using the Events listeners, and viewRenderEventManager but with some dynamic parameters?
    Something like:
    Event::listen('', function ($viewRenderEventManager) {
    $viewRenderEventManager->addTemplate('gtmanager::gtm.head', ['param1' => $param]);

    So I need to insert the view ('gtmanager::gtm.head') from my custom module in the '' location with the parameter 'param1'

    Any idea how can I achieve something like this?


  • Hello @Vlad99 ,
    You can use the view->composer() in your service provider to pass any parameter to the blade where this view_render_event( is already defined, after that inject your template and you can access the parameter in template that you have passed in viewComposer.


  • You can check the AdminServiceProvider under The Admin Package for the reference.

Log in to reply