承接 sibds/yii2-trash-behavior 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sibds/yii2-trash-behavior

最新稳定版本:v0.4.2

Composer 安装命令:

composer require sibds/yii2-trash-behavior

包简介

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

README 文档

README

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

Build Status Scrutinizer Code Quality Code Coverage

Installation

The preferred way to install this extension is through composer.

Either run

$ composer require sibds/yii2-trash-behavior

or add

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

to the require section of your composer.json file.

How to use?

Paste in the model code:

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

To mark a record for deletion, call function delete:

  $model->delete();

The second call delete, delete the record.

To restore record:

  $model->restore();

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

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

Example of use:

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

Selecting only marked for deletion of records:

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

Selecting all records:

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

统计信息

  • 总下载量: 2.62k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 5
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-06