0
无法从数据透视表获得列数据这些都是我的模型获取数据
产品
public function users()
{
return $this
->belongsToMany('App\User')
->withTimestamps()
->withPivot('auth_product');
}
用户
public function products()
{
return $this
->belongsToMany('App\Products')
->withTimestamps()
->withPivot('auth_product');
}
控制器
$authorized_users = Products::find($id)->pivot->auth_user;
它给“尝试获得非客体的财产“。我试图让布尔值
编辑:Succeded中获取价值,但现在给“空”值
$authorized_users = Products::find($id)->first()->pivot['auth_user'];
它给空,但有值下的product_id(用作外键)该列,但它仍然抛出空 – OunknownO