问题描述
-
members
的频道 -
managers
的频道
我写了这个:
<?PHP
class ModelUpdated implements ShouldbroadcastNow
{
use dispatchable,InteractsWithSockets,SerializesModels;
public $model;
public function __construct(Model $model)
{
$this->model = $model;
}
public function broadcastWith($who)
{
if ($who == "model.{$this->model->id}")
return [$this->model->id];
else if ($who == "model.{$this->model->id}.managers")
return [$this->model];
else
return [];
}
public function broadcastOn()
{
return [
new PrivateChannel("model.{$this->model->id}"),new PrivateChannel("model.{$this->model->id}.managers")
];
}
}
不幸的是,broadcastWith
无法与我的$who
魔法配合使用。有替代的方法吗?
我想避免发生不同的事件,因为我的是在模型中触发的:
class MyModel extends Model
{
use Notifiable;
protected $dispatchesEvents = [
'saved' => ModelUpdated::class,'updated' => ModelUpdated::class,];
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)