you need to take count of table first and store it into $count and
NextTitle::latest()->take($count)->skip(3)->delete();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I try to delete everything from a table except the latest three rows.
So i did:
NextTitle::latest()->skip(3)->delete();
But it deletes the whole Table instead of leaving the latest three. What am i doing wrong? i want to delete everything from the table exept the last three entries.
or try this
NextTitle::latest()->take($count)->skip(3)->get()->each(function($row){ $row->delete();});
Please or to participate in this conversation.