Php 第二个参数未传递给Laravel 5.1中的事件
我试图用两个参数构造一个事件,一个布尔值,然后是一个可能为空的第二个参数。有趣的是,我已经有一个事件使用完全相同的设置。但我无法使第二个事件正常运行 以下是运行事件: 当它通过WebSocket在我的前端传输时: 对象{isResuming:false,newTime:null} 这是一个非功能性事件,几乎没有变化。Php 第二个参数未传递给Laravel 5.1中的事件,php,laravel,events,Php,Laravel,Events,我试图用两个参数构造一个事件,一个布尔值,然后是一个可能为空的第二个参数。有趣的是,我已经有一个事件使用完全相同的设置。但我无法使第二个事件正常运行 以下是运行事件: 当它通过WebSocket在我的前端传输时: 对象{isResuming:false,newTime:null} 这是一个非功能性事件,几乎没有变化。 我已经创建了事件类并启动了它们,并且工作正常 Event::fire(new LiveCountdownEvent(true)); Event::fire(new WebcastE
我已经创建了事件类并启动了它们,并且工作正常
Event::fire(new LiveCountdownEvent(true));
Event::fire(new WebcastEvent(true));
日志:
我知道我的答案不能解决您的问题,但它可能会帮助您面对问题。作为测试,您会尝试使用()吗?
<?php
namespace MyProj\Events;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class WebcastEvent extends Event implements ShouldBroadcast
{
use SerializesModels;
public $isActive;
public $videoId;
/**
* Create a new event instance.
*
* @param $isActive
* @param null $videoId
*/
public function __construct($isActive, $videoId = null)
{
$this->isActive = $isActive;
if ($videoId != null) {
$this->videoId = $videoId;
}
}
/**
* Get the channels the event should be broadcast on.
*
* @return array
*/
public function broadcastOn()
{
return ['live-updates'];
}
}
Event::fire(new LiveCountdownEvent(true));
Event::fire(new WebcastEvent(true));
[2015-12-03 12:24:21] local.INFO: Broadcasting [App\Events\LiveCountdownEvent] on channels [live-updates] with payload:
{
"isResuming": true,
"newTime": null
}
[2015-12-03 12:24:21] local.INFO: Broadcasting [App\Events\WebcastEvent] on channels [live-updates] with payload:
{
"isActive": true,
"videoId": null
}