【发布时间】:2021-06-14 19:00:38
【问题描述】:
这是我的代码:
$course = Course::where('id', $activeCourseId)
->with(["blocks.cards" => function($q) use($cardsDueIds) {
$q->whereNotIn('id', $cardsDueIds);
$q->take(50);
},
"blocks.cards.contexts",
"blocks.cards.user_contexts",
"blocks.cards.block.course",
"blocks.cards.thisUser"])
->first();
课程资料如下:
{
blocks: [
0: {
cards: [
0: {id: 298736},
1: {id: 293747}
]
}
1: {
cards: [
0: {id: 1234445}
]
}
]
}
我尝试获取只有 50 个blocks.cards 的课程,其中blocks.cards.id 不在$cardsDueIds 中。
实际上它不起作用,take(50) 我得到 0 张卡片,而没有 take(50) 我得到所有卡片(但 whereNotIn 不起作用)...
有人知道怎么做吗?谢谢!
【问题讨论】:
-
你能打印 $cardsDueIds 是不是这个数组吗?