PHPackages                             josegonzalez/cakephp-deleted-at - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. josegonzalez/cakephp-deleted-at

Abandoned → [muffin/trash](/?search=muffin%2Ftrash)ArchivedCakephp-plugin[Database &amp; ORM](/categories/database)

josegonzalez/cakephp-deleted-at
===============================

Handles soft-deletion of database records

0.0.1(12y ago)4171MITPHP

Since Dec 21Pushed 10y ago2 watchersCompare

[ Source](https://github.com/josegonzalez/cakephp-deleted-at)[ Packagist](https://packagist.org/packages/josegonzalez/cakephp-deleted-at)[ Docs](http://github.com/josegonzalez/cakephp-deleted-at)[ RSS](/packages/josegonzalez-cakephp-deleted-at/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/735173b3fb4be51f4c19dda150649f8f0050d6a1d8ad1661d27a1d3d539d32df/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6a6f7365676f6e7a616c657a2f63616b657068702d64656c657465642d61742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/josegonzalez/cakephp-deleted-at)[![Coverage Status](https://camo.githubusercontent.com/3f6b58daf1d27cf9b90adaafdc03f9c29c705e9f068ea3976f8bd3044ef6fa3d/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6a6f7365676f6e7a616c657a2f63616b657068702d64656c657465642d61742e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/josegonzalez/cakephp-deleted-at?branch=master)[![Total Downloads](https://camo.githubusercontent.com/4af86b63237646a6cc6721228b1ffe748aebde4efa7af7ad07959cd101a0c955/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6f7365676f6e7a616c657a2f63616b657068702d64656c657465642d61742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/josegonzalez/cakephp-deleted-at)[![Latest Stable Version](https://camo.githubusercontent.com/241f5c5b50dc775303e1ecbaa3170c4e5b1b0f91bf32a08c737057fac37dacad/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6f7365676f6e7a616c657a2f63616b657068702d64656c657465642d61742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/josegonzalez/cakephp-deleted-at)[![Documentation Status](https://camo.githubusercontent.com/ad9fdfd358d193b7bd22438c2c76868533c31e8532ee20ee03283853b1cdef9a/68747470733a2f2f72656164746865646f63732e6f72672f70726f6a656374732f63616b657068702d64656c657465642d61742f62616467652f3f76657273696f6e3d6c6174657374267374796c653d666c61742d737175617265)](https://readthedocs.org/projects/cakephp-deleted-at/?badge=latest)[![Gratipay](https://camo.githubusercontent.com/40a48c7b3fc02e9d39dd715fe09e404c4cb2e89288c6ace0773d2aab6913b46f/68747470733a2f2f696d672e736869656c64732e696f2f67726174697061792f6a6f7365676f6e7a616c657a2e7376673f7374796c653d666c61742d737175617265)](https://gratipay.com/~josegonzalez/)

DeletedAt
=========

[](#deletedat)

Handles soft-deletion of database records

Background
----------

[](#background)

Written for the CakeAdvent post on [Build Behaviors](http://josediazgonzalez.com/2013/12/21/building-a-behavior-with-cakephp/)

Requirements
------------

[](#requirements)

- CakePHP 2.x
- PHP 5.3

Installation
------------

[](#installation)

*\[Using [Composer](http://getcomposer.org/)\]*

Add the plugin to your project's `composer.json` - something like this:

```
  {
    "require": {
      "josegonzalez/cakephp-deleted-at": "dev-master"
    }
  }

```

Because this plugin has the type `cakephp-plugin` set in its own `composer.json`, Composer will install it inside your `/Plugins` directory, rather than in the usual vendors file. It is recommended that you add `/Plugins/DeletedAt` to your .gitignore file. (Why? [read this](http://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md).)

*\[Manual\]*

- Download this:
- Unzip that download.
- Copy the resulting folder to `app/Plugin`
- Rename the folder you just copied to `DeletedAt`

*\[GIT Submodule\]*

In your app directory type:

```
  git submodule add -b master git://github.com/josegonzalez/cakephp-deleted-at.git Plugin/DeletedAt
  git submodule init
  git submodule update
```

*\[GIT Clone\]*

In your `Plugin` directory type:

```
git clone -b master git://github.com/josegonzalez/cakephp-deleted-at.git DeletedAt

```

### Enable plugin

[](#enable-plugin)

In 2.0 you need to enable the plugin in your `app/Config/bootstrap.php` file:

```
CakePlugin::load('DeletedAt');

```

If you are already using `CakePlugin::loadAll();`, then this is not necessary.

Usage
-----

[](#usage)

Add the column `deleted` to your model's table. It should be of type `datetime`, with a default of null.

And add the behavior to your model:

```
