我试图找到一个有条件的行,那是......
用户有很多个人资料图片,但有一张图片是is_main
所以这就是我写的
public function profile_picture()
{
return $this->hasMany('App\User_profile_picture');
}
public function active_picture()
{
return $this->profile_picture()->find($this->is_main);
}
现在当我通过它访问它
$picture = Auth::user()->active_picture;
它说
Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation
我需要做些什么才能使它发挥作用?