【发布时间】:2021-01-08 08:44:12
【问题描述】:
我正在尝试根据多个 whereHas 条件来获取用户。首先,我得到具有特定角色的用户,然后我想对具有其他 whereHas 条件的用户进行排序。我尝试了一些 sn-ps 但我得到了所有具有不同角色的用户。
我的模特
public function document()
{
return $this->hasOne(UserDocument::class,'user_id');
}
public function portfolios()
{
return $this->hasMany(Portfolio::class,'user_id');
}
控制器
public function index()
{
$data = User::whereHas("roles", function($q)
{
$q->where("name", "Seller");
})
->whereHas('portfolios',function($q){
$q->where('status','Pending');
})
->orWhereHas('document',function($s){
$s->where('status','Pending');
})
->get();
dd($data);
return view('admin.pendingapproval.index');
}
我不明白如何做到这一点。请帮帮我
谢谢
【问题讨论】: