0

There is my code :

$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();

Course datas are like this :

{
  blocks: [
    0: {
      cards: [
       0: {id: 298736},
       1: {id: 293747}
      ]
    }
    1: {
      cards: [
       0: {id: 1234445}
      ]
    }
  ]
}

I try to get the course with only 50 blocks.cards where blocks.cards.id are not in the $cardsDueIds.

Actually it does not work, with take(50) i get 0 cards and without take(50) i get all cards (but the whereNotIn doesnt work)...

Anyone know how to do this ? Thanks !

Tony S
  • 491
  • 6
  • 26

2 Answers2

1
$q->whereNotIn('id', $cardsDueIds)->take(50);

If doesn't work, Refer to this thread.

JawadR1
  • 379
  • 3
  • 16
0

Please refrase your question (you say twice the same):

Actually it does not work, with take(50) i get 0 cards and with take(50) i get all cards...

Kachelle
  • 61
  • 6