15 September 2013

Implement Archive feature in Cakephp

Many times when we create a web application, generally we require a very common feature that is very similar to window's recycle bin. In terms of Web Application we also call it Archive which basically means mark the record as delete but not physically.
Last week while working on a web project, I had to implement this feature in my cakephp Application that was really easy to implement using small few steps.

Using below mentioned Steps you can add this feature in your application 
  • Create two fields  "deleted" and "deleted_date" fields on your database table.
  • Download and copy this behavior to app/Model/Behavior.There are ready made Cakephp based behaviors available, that can be used,  but I had used CakeDC Utils SoftDelete Behavior. Click Here  to Download it.
  • Add the behavior to the $actsAs member of the model
  • class User extends AppModel {
    var $actsAs = array('SoftDeletable');
Now whenever you perform a delete action on any record, then it won’t delete that record permanently and you can always retain that record

No comments:

Post a Comment