How to delete a record from the database using Eloquent in Laravel?

To delete a record from the database using Eloquent in Laravel, you can use the delete() method. Here are the steps:

  1. Get an instance of the model by querying the record you want to delete using the appropriate Eloquent query methods like find(), where(), etc. For example:
$record = ModelName::find($id);
  1. Once you have the record, you can call the delete() method on it. For example:
$record->delete();

Alternatively, you can directly chain the delete() method after querying the record. For example:

ModelName::where('column', 'value')->delete();

Note: The delete() method will remove the record from the database permanently. If you want to soft delete the record (i.e., mark it as deleted without actually removing it from the database), you can use the delete() method on a model that uses the SoftDeletes trait.