Laravel 5 Laravel Elotent不调用关系(返回字符串)

Laravel 5 Laravel Elotent不调用关系(返回字符串),laravel-5,eloquent,Laravel 5,Eloquent,我有这样的关系: "effects" 一家商店可能有很多产品,每种产品都有很多效果 存储和产品->多对多关系 产品和效果->一对多(一个产品可以有多种效果) 以下是我的人际关系: $store = Store::where('slug', 'cantina')->first(); dd($store->products->first()->effects); 商店模式 public function products() { return $t

我有这样的关系:

"effects"
一家商店可能有很多产品,每种产品都有很多效果

存储
产品
->多对多关系

产品
效果
->一对多(一个产品可以有多种效果)

以下是我的人际关系:

    $store = Store::where('slug', 'cantina')->first();
    dd($store->products->first()->effects);
商店模式

public function products()
{
    return $this->belongsToMany('App\Models\Product');
}
public function stores()
{
    return $this->belongsToMany('App\Models\Store');
}

public function effects()
{
    return $this->hasMany('App\Models\Effect');
}
public function products()
{
    return $this->belongsTo('App\Models\Product');
}
产品型号

public function products()
{
    return $this->belongsToMany('App\Models\Product');
}
public function stores()
{
    return $this->belongsToMany('App\Models\Store');
}

public function effects()
{
    return $this->hasMany('App\Models\Effect');
}
public function products()
{
    return $this->belongsTo('App\Models\Product');
}
效果模型

public function products()
{
    return $this->belongsToMany('App\Models\Product');
}
public function stores()
{
    return $this->belongsToMany('App\Models\Store');
}

public function effects()
{
    return $this->hasMany('App\Models\Effect');
}
public function products()
{
    return $this->belongsTo('App\Models\Product');
}
现在,我可以访问与产品的关系,但当我访问效果关系时:

    $store = Store::where('slug', 'cantina')->first();
    dd($store->products->first()->effects);
dd返回一个包含关系名称的字符串:

"effects"
我以前从未见过这个“错误”,有人知道为什么这段关系返回的是字符串而不是雄辩的

[编辑]

如果我在关系调用中输入任何数字,他们将输出我输入的数字:

dd($store->products->first()->effects);
//Output:
"effects"
另一个例子:

dd($store->products->first()->foobar);
//Output:
"foobar"

所以关系是商店有多种产品,产品可以有多种效果?这是非常奇怪的行为。你不是以任何方式凌驾于雄辩之上吗,无论是手动的、通过特质的还是通过直接扩展雄辩以外的东西的方式?也许可以在
\u get
魔术方法上查找覆盖?如果你需要一只手来识别,请发布你的模型代码。嘿@TomasButeler,你的回复帮助我解决了我的问题,我的模型使用了错误的acessor,因此,返回了一个字符串。谢谢你,伙计!很高兴听到这个消息!如果你有时间,请发布(并接受)一个答案,详细说明你做错了什么。是的,我明天会做!所以关系是商店有多种产品,产品可以有多种效果?这是非常奇怪的行为。你不是以任何方式凌驾于雄辩之上吗,无论是手动的、通过特质的还是通过直接扩展雄辩以外的东西的方式?也许可以在
\u get
魔术方法上查找覆盖?如果你需要一只手来识别,请发布你的模型代码。嘿@TomasButeler,你的回复帮助我解决了我的问题,我的模型使用了错误的acessor,因此,返回了一个字符串。谢谢你,伙计!很高兴听到这个消息!如果你有时间,请发布(并接受)一个答案,详细说明你做错了什么。是的,我明天会做!