【发布时间】:2015-07-08 10:29:54
【问题描述】:
我正在尝试在 Laravel 5.1 中实现事件。触发时的事件将发送邮件。
我做了以下步骤:
首先,在 EventServiceProvider 中,我在 $listen 中添加了这个
'send.mail' => [
\App\Listeners\CreateTicketMail::class,
],
其次,创建了一个新的 Event 类——SendActionEmails。
然后是 Listener 类中此事件的处理程序 - CreateTicketMail
public function handle(SendActionEmails $event)
{
dd($event);
}
现在当我触发这个事件send.mail 时,我得到一个错误
Event::fire('check.fire');
Argument 1 passed to App\Listeners\CreateTicketMail::handle() must be an instance of App\Events\SendActionEmails, none given
另外,我在哪里可以将数据发送到邮件将使用的事件。数据喜欢到,从,主题。
我发现在触发事件时,作为参数传递给火的一种方法。
Event::fire('check.fire', array($data));
但是,我如何在监听器中处理这些数据???
【问题讨论】:
标签: php events laravel laravel-5 laravel-5.1