{"id":13411534,"url":"https://github.com/cornernote/yii2-softdelete","last_synced_at":"2025-05-05T21:15:40.102Z","repository":{"id":56958128,"uuid":"37762218","full_name":"cornernote/yii2-softdelete","owner":"cornernote","description":"Soft delete behavior for Yii2","archived":false,"fork":false,"pushed_at":"2017-09-13T23:13:07.000Z","size":48,"stargazers_count":23,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-05T21:15:35.676Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cornernote.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-20T07:44:24.000Z","updated_at":"2025-01-06T03:05:07.000Z","dependencies_parsed_at":"2022-08-21T08:50:57.434Z","dependency_job_id":null,"html_url":"https://github.com/cornernote/yii2-softdelete","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornernote%2Fyii2-softdelete","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornernote%2Fyii2-softdelete/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornernote%2Fyii2-softdelete/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornernote%2Fyii2-softdelete/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cornernote","download_url":"https://codeload.github.com/cornernote/yii2-softdelete/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252577026,"owners_count":21770721,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:14.311Z","updated_at":"2025-05-05T21:15:40.068Z","avatar_url":"https://github.com/cornernote.png","language":"PHP","funding_links":[],"categories":["Behaviors 行为"],"sub_categories":[],"readme":"# Yii2 Soft Delete\n\n[![Latest Version](https://img.shields.io/github/tag/cornernote/yii2-softdelete.svg?style=flat-square\u0026label=release)](https://github.com/cornernote/yii2-softdelete/tags)\n[![Software License](https://img.shields.io/badge/license-BSD-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Build Status](https://img.shields.io/travis/cornernote/yii2-softdelete/master.svg?style=flat-square)](https://travis-ci.org/cornernote/yii2-softdelete)\n[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/cornernote/yii2-softdelete.svg?style=flat-square)](https://scrutinizer-ci.com/g/cornernote/yii2-softdelete/code-structure)\n[![Quality Score](https://img.shields.io/scrutinizer/g/cornernote/yii2-softdelete.svg?style=flat-square)](https://scrutinizer-ci.com/g/cornernote/yii2-softdelete)\n[![Total Downloads](https://img.shields.io/packagist/dt/cornernote/yii2-softdelete.svg?style=flat-square)](https://packagist.org/packages/cornernote/yii2-softdelete)\n\nSoft delete behavior for Yii2.\n\n\n## Installation\n\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\n\nEither run\n\n```\n$ composer require cornernote/yii2-softdelete \"*\"\n```\n\nor add\n\n```\n\"cornernote/yii2-softdelete\": \"*\"\n```\n\nto the `require` section of your `composer.json` file.\n\n\n## Usage\n\nIn your ActiveRecord class:\n\n```php\npublic function behaviors() {\n    return [\n        \\cornernote\\softdelete\\SoftDeleteBehavior::className(),\n        // or\n        [\n            'class' =\u003e \\cornernote\\softdelete\\SoftDeleteBehavior::className(),\n            'attribute' =\u003e 'deleted_time',\n            'value' =\u003e new \\yii\\db\\Expression('NOW()'), // for sqlite use - new \\yii\\db\\Expression(\"date('now')\")\n        ],\n    ];\n}\n```\n\nthen you can use explicitly `$model-\u003esoftDelete()`, `$model-\u003ehardDelete()`\nand `$model-\u003eunDelete()` (for softly deleted models). Each of these methods return\nboolean result. Also `$model-\u003esoftDelete()` calls indirectly from `$model-\u003edelete()`,\nwhich always returns `false`.\n\nIn your ActiveQuery class:\n\n```php\npublic function behaviors() {\n    return [\n        \\cornernote\\softdelete\\SoftDeleteQueryBehavior::className(),\n        // or\n        [\n            'class' =\u003e \\cornernote\\softdelete\\SoftDeleteQueryBehavior::className(),\n            'attribute' =\u003e 'deleted_time',\n        ],\n    ];\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcornernote%2Fyii2-softdelete","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcornernote%2Fyii2-softdelete","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcornernote%2Fyii2-softdelete/lists"}