Search code examples
laraveleventspusherdispatch

Laravel event dispatch in web.php


I just wanted to use event broadcasting in Laravel and I followed a tutorial video. But problem shows up in the beginning. The tutorial shows what to do in web.php and it goes like this:

Route::get( uri: '/'. action: function () {
   eventName::dispatch();
   return view( view: 'welcome');
});

The problem is I have a different route formula in my web.php which is like this:

Route::get('{path}', SpaController::class)->where('path', '(.*)');

The question is, how to dispatch the event in my web.php?


Solution

  • Solve based on @ceejayoz's comment:

       The tutorial is showing a quick, no-controller approach. You would call 
       eventName::dispatch(); within your SpaController.