InterviewSolution
Saved Bookmarks
| 1. |
What are the difference between softDelete() & delete() in Laravel? |
|
Answer» 1. delete() In case when we used to delete in Laravel then it REMOVED records from the database table. Example:$delete = Post::where(‘id’, ‘=’, 1)->delete(); 2. softDeletes()To delete records permanently is not a good THING that’s why laravel used features are called SoftDelete. In this case, records did not REMOVE from the table only delele_at VALUE updated with current date and time. use SoftDeletes; $softDelete = Post::where(‘id’, ‘=’, 1)->delete(); OR $softDelete = Post::where(‘id’, ‘=’, 1)->softDeletes(); |
|