Source: ryangjchandler.co.uk

Delete All Rows for a Laravel Model

Category: Laravel, Laravel

There are 2 way to delete all of the records for a model. This is perfect for when you don't need to modify which records are being deleted and just want to delete all of them. If you wanted to add some constraints onto the deletion, you'd likely want to use this method. The ::query() method just returns a new Builder instance, so you can chain you extra methods with, some, intellisense.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners