首先,我对标题感到抱歉,但我无法说清楚。只是让我知道所以我可以对其进行编辑。
我想检查是否有多个用户满足说某种语言的标准。作为参考,您可以看到european language reference
我在以下方面可以找到使用其语言的正确用户:
// Check for language filter
if($request->has('language')){
/*
* havingRaw() is working without a groupBy because of `ONLY_FULL_GROUP_BY`
* disabled at database.php. I couldn't make it work without disabling this
* mode
* */
$candidates->whereHas('user.languages', function ($q) use ($request) {
$q->whereIn('language_id', $request->language);
$q->havingRaw('count(language_id) >= ' . count($request->language));
});
}
$candidates
是JobsApplications
的集合。我希望能够执行以下操作:
// Check for language filter
if($request->has('language')) {
$candidates->whereHas('user.languages', function ($q) use ($request) {
$q->whereIn('language_id', $request->language);
$q->havingRaw('count(language_id) >= ' . count($request->language));
$q->where('speaking', '>=', 'B1');
// apply the filter for each field (speaking, speaking, writting)
});
}
我该怎么做呢?值得注意的是,$request->language
是一个数组,其中还有另外三个数组$request->speaking[]
,$request->writting[]
和$request->comprehension[]
。