rahulabs/yii2-softdelete 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

rahulabs/yii2-softdelete

最新稳定版本:1.0.1

Composer 安装命令:

composer require rahulabs/yii2-softdelete

包简介

Soft delete extension for Yii2 framework

README 文档

README

Soft delete extension for Yii2 framework.

This extension ensures that soft-deleted has delete native consistent behavior and is IDE-friendly.

Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist rahulabs/yii2-softdelete "*"

or add

"rahulabs/yii2-softdelete": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

Edit model class:

use rahulabs\softdelete\behaviors\SoftDeleteBehavior;
use rahulabs\softdelete\SoftDelete;

class Model extends \yii\db\ActiveRecord
{
    use SoftDelete;

    public function behaviors()
    {
        return [
            'class' => SoftDeleteBehavior::className(),
        ];
    }
}

Change database table structures, add deleted_at (int 11) field and attached to UNIQUE index.

API

ActiveRecord class (SoftDelete Trait):

The find series method will return rahulabs\softdelete\ActiveQuery Object.

  • softDelete() Deleting data using soft delete mode
  • forceDelete() Use physical deletion mode to force delete data
  • restore() Recover soft deleted model data
  • isTrashed() Whether it is soft deleted

The following commands are find() / findOne() / findAll() Corresponding versions in different modes :

All models (including soft deleted ones):

  • findWithTrashed()
  • findOneWithTrashed($condition)
  • findAllWithTrashed($condition)

Find only soft deleted models :

  • findOnlyTrashed()
  • findOneOnlyTrashed($condition)
  • findAllOnlyTrashed($condition)

The following commands have been rewritten as soft delete versions :

  • find()
  • findOne()
  • findAll()
  • delete()

rahulabs\softdelete\ActiveQuery

increased withTrashed(), withoutTrashed() and onlyTrashed() Three methods, Set the corresponding search mode。

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-06