2017 © Pedro Peláez
 

yii2-behaviors yii2-trash-behavior

AR models behavior that allows to mark models as deleted and then restore them.

image

sibds/yii2-trash-behavior

AR models behavior that allows to mark models as deleted and then restore them.

  • Wednesday, May 17, 2017
  • by mazurva
  • Repository
  • 5 Watchers
  • 2 Stars
  • 2,023 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 2 % Grown

The README.md

yii2-trash-behavior

AR models behavior that allows to mark models as deleted and then restore them., (*1)

Build Status Scrutinizer Code Quality Code Coverage, (*2)

Installation

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

Either run, (*4)

$ composer require sibds/yii2-trash-behavior

or add, (*5)

"sibds/yii2-trash-behavior": "*"

to the require section of your composer.json file., (*6)

How to use?

Paste in the model code:, (*7)

  public function behaviors()
  {
      return [
          \sibds\behaviors\TrashBehavior::className(),
      ];
  }

To mark a record for deletion, call function delete:, (*8)

  $model->delete();

The second call delete, delete the record., (*9)

To restore record:, (*10)

  $model->restore();

For the correct selection of records in the model, it is necessary to redefine the function of find:, (*11)

  public static function find()
  {
      return (new \sibds\behaviors\TrashQuery(get_called_class()))->findRemoved();
  }

Example of use:, (*12)

  $posts = Post::find()->all();

Selecting only marked for deletion of records:, (*13)

  $count = Post::find()->onlyRemoved()->count();

Selecting all records:, (*14)

  $allPosts = Post::find()->withRemoved()->all();

The Versions

17/05 2017

dev-master

9999999-dev https://github.com/sibds/yii2-trash-behavior

AR models behavior that allows to mark models as deleted and then restore them.

  Sources   Download

MIT

The Requires

 

The Development Requires

yii2 behavior active record trash

17/05 2017

v0.4

0.4.0.0 https://github.com/sibds/yii2-trash-behavior

AR models behavior that allows to mark models as deleted and then restore them.

  Sources   Download

MIT

The Requires

 

The Development Requires

yii2 behavior active record trash

17/05 2017

v0.4.2

0.4.2.0 https://github.com/sibds/yii2-trash-behavior

AR models behavior that allows to mark models as deleted and then restore them.

  Sources   Download

MIT

The Requires

 

The Development Requires

yii2 behavior active record trash

16/02 2016

v0.3

0.3.0.0 https://github.com/sibds/yii2-trash-behavior

AR models behavior that allows to mark models as deleted and then restore them.

  Sources   Download

MIT

The Requires

 

The Development Requires

yii2 behavior active record trash

15/06 2015

dev-scrutinizer-patch-1

dev-scrutinizer-patch-1 https://github.com/sibds/yii2-trash-behavior

AR models behavior that allows to mark models as deleted and then restore them.

  Sources   Download

MIT

The Requires

 

The Development Requires

yii2 behavior active record trash

15/06 2015

v0.2

0.2.0.0 https://github.com/sibds/yii2-trash-behavior

AR models behavior that allows to mark models as deleted and then restore them.

  Sources   Download

MIT

The Requires

 

The Development Requires

yii2 behavior active record trash