Giter Club home page Giter Club logo

delete's Introduction

CakePHP plugin for soft deleting

Build Status Scrutinizer Code Quality LICENSE Releases

This Delete plugin enable soft deletable. Entities aren't removed from your database. Instead, a deleted timestamp is set on the record.

Requirements

It is developed for CakePHP 4.x.

Installation

You can install plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require slicesofcake/delete

Load the Behavior

Load the Behavior in your src/Model/Table/YourTable.php (or if you have AppTable.php). The default field named in database table should be deleted (like created or modified) and compatible type with Time::now() (eg. DATE or DATETIME).

public function initialize(array $config)
{
    parent::initialize($config);

    $this->addBehavior('SlicesCake/Delete.Deleted');
}

You can configuration to customize the Delete plugin:

$this->addBehavior('SlicesCake/Delete.Deleted', [
    'field' => 'deleted_at', // Change column field name
]);

Add column by Migrations plugin

  1. Load Migrations plugin (https://github.com/cakephp/migrations).
  2. Copy file from /vendor/slicesofcake/delete/config/20200101122906_AddDeletedToProducts.example.php to your app main config directory.
  3. Rename to 20200101122906_AddDeletedTo[YourTable].php.
  4. Edit file and rename class with changes above.
  5. Update change method to set table name.
  6. Run migrations by command: cake migrations migrate

delete's People

Contributors

kicaj avatar stickler-ci avatar

Watchers

 avatar  avatar

delete's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.