I’m trying to eliminate duplicates from a table but the query I’m using deletes the entire database and not the duplicates, can you tell me why and what I can do? Thank you very much in advance to the whole community..
This is code
$ids = EsitiAudit::
groupBy(['master_zone', 'subarea', 'microarea', 'frequency_audit', 'data_audit', 'esito', 'employee', 'eseg_riass', 'categoria'])->get(['id'])->all();
EsitiAudit::whereNotIN('id', $ids)->delete();
2
Answers
You’re passing complete elements to the
->delete()
query, try this instead:Pick just the ids from the elements on the query and then delete the files.