title: Running Javascript in Laravel 5.7 event listener
body: <p>I am trying to run a javascript library, Noty, upon user login. I've already registered the event and followed the documentation <a href="https://laravel.com/docs/5.7/events" rel="nofollow noreferrer">here</a>. However I tried to use echo to send down the javascript, but the code isn't executing from what I can see. The workflow is that upon login in the <code>Home</code> page a noty notification will pop up saying welcome. </p>
  
  <p>Here is my <code>EventServiceProvider</code>:</p>
  
  <pre><code>class EventServiceProvider extends ServiceProvider
  {
      /**
       * The event listener mappings for the application.
       *
       * @var array
       */
      protected $listen = [
          Registered::class =&gt; [
              SendEmailVerificationNotification::class,
          ],
          'Illuminate\Auth\Events\Login' =&gt; ['App\Listeners\UserEventListener@onUserLogin']
      ];
  
      /**
       * Register any events for your application.
       *
       * @return void
       */
      public function boot()
      {
          parent::boot();
  
  
      }
  }
  </code></pre>
  
  <p><code>UserEventListener</code>:</p>
  
  <pre><code>class UserEventListener
  {
      /**
       * Create the event listener.
       *
       * @return void
       */
      public function __construct()
      {
          //
      }
  
      /**
       * Handle the event.
       *
       * @param  Login  $event
       * @return void
       */
      public function handle(Login $event)
      {
  
      }
  
      public function onUserLogin($event) {
           echo("&lt;script&gt;
              $(document).ready(function() {
                      new Noty({
                      text: 'Welcome {{Auth::user()-&gt;name}}! ',
                      type:'info',
                      layout: 'centerRight',
                      timeout:2000
                  })
                  .on('onShow', function() {
                          var audio = new Audio('/sounds/appointed.mp3');
                          audio.play();
                      }).show();
              });
          &lt;/script&gt;");
          echo("adad");
      }
  }
  </code></pre>