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

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

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

sbilyalov/yii2-softdelete

Composer 安装命令:

composer require sbilyalov/yii2-softdelete

包简介

Soft delete behavior for Yii2 framework

README 文档

README

This behaviour added soft-delete functionality to your active record

##Installation

The preferred way to install this extension is through composer.

Run:

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

or add

"sbilyalov/yii2-softdelete": "*"

to your composer.json file.

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

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:

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();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2016-03-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固