If I use $table->softDeletes()
in a migration, a deleted_at timestamp nullable column is added to the table.
From now on I can come to the conclusion that any query against this table via eloquent will carry a WHERE deleted_at IS NULL
clause, assuring only live records are returned.
But I noticed there is no index created for deleted_at. Shouldn't be paramount for this column to have an index?
I hope I'm missing something.
According to this answer, you should not index your deleted_at column. There will be no beneficial impact on performance.
To soft delete a model you may use: $model = Contents::find( $id ); $model->delete(); Deleted (soft) models are identified by the timestamp and if deleted_at field is NULL then it's not deleted and using the restore method actually makes the deleted_at field NULL .
According to this answer, you should not index your deleted_at column. There will be no beneficial impact on performance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With