简体   繁体   中英

Method Illuminate\Support\Collection::exists does not exist

I am trying to send mail to user. I don't know why its shows error.

$unUsedModuleIds=!$modulesIds->whereIn('id',$usedModuleIds)->exists();

when add this statement it's showing error.

foreach ($ModuleAutoMail as $module) {
    if ($mail->condition_id == '3') {

        $last_used_module = Carbon::parse($module->last_used_module);
        $DeferenceInDays = Carbon::parse(Carbon::now())->diffInDays($last_used_module);

        $usedModuleIds = module_auto_mail::where('user_id', $user_id)->pluck('module_id');
        $unUsedModuleIds = !$modulesIds->whereIn('id', $usedModuleIds)->exists();


        if ($unUsedModuleIds) {
            $ableToSendMail = true;
        }

        if ($DeferenceInDays > 7) {
            $ableToSendMail = false;
        }

    }
}

Try this

foreach($ModuleAutoMail as $module) {

    if($mail->condition_id=='3' ){  

        $last_used_module = Carbon::parse($module->last_used_module);
        $DeferenceInDays = Carbon::parse(Carbon::now())->diffInDays($last_used_module);

        $usedModuleIds = module_auto_mail::where('user_id',$user_id)->pluck('module_id')->toArray();
        $unUsedModuleIds= module_auto_mail::whereIn('id',array_values($usedModuleIds))->get();


        if(count($unUsedModuleIds) > 0){
            $ableToSendMail = true;
        }

        if ($DeferenceInDays > 7) {
            $ableToSendMail = false;
         }

    }
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM