The problem is that I have a huge list of emails (750,000 verified Emails ) and I want to loop on it against a users table that also has a huge number of records (800,000 users) and delete users that their emails is not exists in the verified email list I tried to to use chunks , but I think I use it in wrong way, For example :
$users = User::query()->wherehas('emails_email')->chunk(10, function ($users) {
foreach ($users as $user) {
echo $user->name ;
}
});
return response()->json($users)