Deleting record is very simple if we will use Laravel query builder. We will create our query and instead of using get() or first() we will call delete function. For example,
DB::table( 'leads' ) ->where( 'email', '=', '[email protected]' ) ->delete();
We can also delete multiple records which fulfil where() condition.
DB::table( 'leads' ) ->where( 'points', '<', '10' ) ->delete();
We can also delete all records in some table using truncate() method.
We must use this truncate() method very carefully. I hope now deleting records using Laravel query builder is very simple for you. If you have any questions please leave a comment. We appreciate that. Enjoy learning.