Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Physical delete a model which is enabled softdelete in laravel5?

I am using SoftDeletes for a model in Laravel5.

But in some cases (Keeping history is not useful),I want to do physical delete (Removing row from table)instead of softDelete.

    class PaymentInvoices extends Model {

    use SoftDeletes;
}

Is there any method for forcing physical delete?

like image 361
gsk Avatar asked Mar 16 '23 16:03

gsk


1 Answers

Of course there is. Use forceDelete method instead of just delete.

Keep in mind, forceDelete is only available if you use the SoftDeletes trait.

Example

$instance->delete() //This is a soft delete
$instance->forceDelete() // This is a 'hard' delete

More info here (scroll down to Permanently Deleting Models)

like image 127
Harry Geo Avatar answered Mar 18 '23 05:03

Harry Geo