Eager Load Constraints Filter issue in Laravel

前端 未结 1 1295
暖寄归人
暖寄归人 2021-01-15 01:37

I am unable to filter the contents of groups table with respect to username in users table using Eager Load Constraints



        
1条回答
  •  被撕碎了的回忆
    2021-01-15 01:57

    Think it should be something like this:

    Groups::with('User')->whereHas('User', function($q) use ($key){
     $q->where('username', 'like', '%'.$key.'%');
    })->where('status', 1)->paginate($pagVal);
    

    0 讨论(0)
提交回复
热议问题