Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在附加事件时创建观察者_Php_Laravel_Observers - Fatal编程技术网

Php 如何在附加事件时创建观察者

Php 如何在附加事件时创建观察者,php,laravel,observers,Php,Laravel,Observers,我有一个多对多关系,我需要在附加关系后运行一个函数 我的网络研讨会模式: protected$table='webinar_instances'; 受保护的$connection='mysql'; 公共职能教师() { 返回$this->belongstomy('Modules\Integration\Entities\Teacher',网络研讨会InstanceTeacher::class, “网络研讨会id”,“教师id”)->带Pivot(“天空教师id”); } 我的老师模式: pro

我有一个多对多关系,我需要在附加关系后运行一个函数

我的网络研讨会模式:

protected$table='webinar_instances';
受保护的$connection='mysql';
公共职能教师()
{
返回$this->belongstomy('Modules\Integration\Entities\Teacher',网络研讨会InstanceTeacher::class,
“网络研讨会id”,“教师id”)->带Pivot(“天空教师id”);
}
我的老师模式:

protected$connection='mysql_hamyaad';
受保护的$table='teachers';
受保护的$fillable=[];
公共功能网络研讨会实例()
{
返回$this->belongTomany(WebinarInstance::class、'webinarInstances\u teachers'、'teacher\u id'、'webinar\u id');
}
我的枢轴模型

protected$connection='mysql';
受保护的$fillable=[];
受保护的$table='webinnar.webinar\u
但不运行我的观察者:

公共函数启动()
{
父::boot();
Pivot::已保存(函数($Pivot){
dd($枢轴);
});
}

有人能帮我做到这一点吗?

Pivot不是一个雄辩的模型,这就是为什么您的观察者没有运行,可能您想使用
附加、分离或同步
检查使用此选项