I have two tables SCHOLAR and MEMBER table. I want to display list of scholars from Scholar table which scholar_id doesn't found in Member table. But the result of my Second dd is empty which actually it has data in database. What am i doing wrong?I think my code is fine.
public function list()
{
$scholars = Member::all();
$scholar_ids = [];
foreach ($scholars as $scholar) {
array_push($scholar_ids, $scholar->scholar_id);
}
$scholar_exits = Scholar::where('scholar_id','=', $scholar_ids)->get();
<!-- First -->
dd($scholar_ids);
<!-- Second -->
dd($scholar_exits);
}
<!-- First dd result -->
array:7 [▼
0 => 7
1 => 8
2 => 12
3 => 13
4 => 14
5 => 15
6 => 16
]
<!-- Second dd result -->
Collection {#275 ▼
#items: []
}
Hope anyone can help me here.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire