2017 © Pedro Peláez
 

yii2-behavior yii2-softdelete

Soft delete behavior for Yii2 framework

image

sbilyalov/yii2-softdelete

Soft delete behavior for Yii2 framework

  • Wednesday, March 23, 2016
  • by seydamet
  • Repository
  • 1 Watchers
  • 1 Stars
  • 44 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 7 % Grown

The README.md

Yii2 Soft Delete

This behaviour added soft-delete functionality to your active record, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Run:, (*3)

php composer.phar require  --prefer-dist sbilyalov/yii2-softdelete "*"

or add, (*4)

"sbilyalov/yii2-softdelete": "*"

to your composer.json file., (*5)

Usage

use sbilyalov\yii2\behaviors\SoftDelete;

public function behaviors ()
{
    return [
        SoftDeleteBehavior::className()
    ];
}

By default the SoftDelete behavior fills the is_deleted attribute with the number - 1, (*6)

If your attribute names are different or you want to use a different way of mark deleted record you may configure the [[attribute]] and [[value]] properties like the following:, (*7)

use sbilyalov\yii2\behaviors\SoftDelete;
use yii\db\Expression;

public function behaviors ()
{
    return [
        [
            'class' => SoftDeleteBehavior::className(),
            'attribute' => 'deleted_time',
            'value' => new Expression('NOW()'),
            'restoreValue' => null
        ]
    ];
}

Additional functions for active record model

// soft delete model
$model->remove();

// delete soft-deleted model from database
$model->forceDelete();

// restore soft-deleted model
$model->restore();

// call SoftDelete::remove()
$model->delete();

The Versions

23/03 2016

dev-master

9999999-dev

Soft delete behavior for Yii2 framework

  Sources   Download

The Requires

 

by Seydamet Bilyalov

yii2 behavior soft delete soft-delete delete behavior

23/03 2016

1.0.0

1.0.0.0

Soft delete behavior for Yii2 framework

  Sources   Download

The Requires

 

by Seydamet Bilyalov

yii2 behavior soft delete soft-delete delete behavior