问题描述
我正在建立模型,并使用chelout / laravel-relationship-events捕获事件。
我有一个看起来像这样的模型:
class Taxonomyterm extends Model
{
use HasMorphToManyEvents,HasMorphedByManyEvents {
HasMorphedByManyEvents::newMorphToMany insteadof HasMorphToManyEvents;
}
...
public function images()
{
return $this->morphToMany(Image::class,'imageable')->withTimestamps();
}
public function items()
{
return $this->morphedByMany(Item::class,'taxonomytermable')->orderBy('taxonomytermables.id')->withPivot('id')->withTimestamps();
}
...
protected static function boot()
{
parent::boot();
static::morphToManyAttached(function ($relation,$parent,$ids,$attributes) {
if( $relation == 'images') {
dd('Attached MorphToMany');
}
}
static::morphedByManyAttached(function ($relation,$attributes) {
if( $relation == 'items') {
dd('Attached MorphedByMany');
}
}
}
该软件包的维护者向我指出了PHP docs,但似乎找不到正确的方法来完成这项工作。
我还假设newMorphToMany是两个特征之间冲突的方法。
从本质上我迷失了如何使HasMorphToManyEvents和HasMorphedByManyEvents在同一模型上工作。 Package this is from
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)