您需要在 EventServiceProvider 中注册事件
protected $listen = [
'Mikea\Kicker\Events\Interviews\SurveyWasCompleted' => [
'Mikea\Kicker\Listeners\SurveyWasCompletedListener',
]
];
然后你需要创建一个监听器SurveyWasCompletedListener
namespace Mikea\Kicker\Listeners;
use Mikea\Kicker\Events\Interviews\SurveyWasCompleted;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class SurveyWasCompletedListener
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param SurveyWasCompleted $event
* @return void
*/
public function handle(SurveyWasCompleted $event)
{
//do something
}
}
显然你需要使用触发事件
Event::fire(new SurveyWasCompleted($data));