diff --git a/modules/newsletter/ajax/table.php b/modules/newsletter/ajax/table.php index c4979b8eb..a03bade52 100644 --- a/modules/newsletter/ajax/table.php +++ b/modules/newsletter/ajax/table.php @@ -33,15 +33,15 @@ if (!empty($search)) { $destinatari = $riferimento->destinatari() ->where(function ($query) use ($results) { $query->where('record_type', '=', Anagrafica::class) - ->whereIn('record_id', $results['anagrafica']); + ->whereIn('record_id', (!empty($results['anagrafica']) ? $results['anagrafica']->toArray() : [])); }) ->orWhere(function ($query) use ($results) { $query->where('record_type', '=', Sede::class) - ->whereIn('record_id', $results['sede']); + ->whereIn('record_id', (!empty($results['sede']) ? $results['sede']->toArray() : [])); }) ->orWhere(function ($query) use ($results) { $query->where('record_type', '=', Referente::class) - ->whereIn('record_id', $results['referente']); + ->whereIn('record_id', (!empty($results['referente']) ? $results['referente']->toArray() : [])); }); } // Elenco di tutti i destinatari