betalabs/laravel5-soft-cascade
Composer 安装命令:
composer require betalabs/laravel5-soft-cascade
包简介
Soft Delete & Restore Cascader
README 文档
README
Laravel/Lumen 5 Soft Cascade Delete & Restore
Cascade delete and restore when using the Laravel or Lumen SoftDeletes feature.
Why do I need it?
To make soft deleting and restoring relations easy.
If you enjoy features like MySQL cascade deleting but want to use Laravels SoftDeletes feature you'll need to do some extra steps to ensure your relations are properly deleted or restored.
This package is intended to replace those steps with a simple array that defines the relations you want to cascade.
Installation
Install with composer
composer require askedio/laravel5-soft-cascade
Register the service provider in your config/app.php
Laravel:
Askedio\SoftCascade\Providers\GenericServiceProvider::class,
Lumen:
Askedio\SoftCascade\Providers\LumenServiceProvider::class,
Usage
In your Model enable the trait and define $softCascade. Example.
use \Askedio\SoftCascade\Traits\SoftCascadeTrait;
protected $softCascade = ['profiles'];
$softCascade is an array of your relation names, in the example you'll see we've defined function profiles() for the relation.
Nested relations work by defining $softCascade in the related Model as you can see here.
After you've defined your relations you can simply trigger delete() or restore() on your Model and your relations will have the same task performed.
User::first()->delete();
User::withTrashed()->first()->restore();
Supported Databases
- MySQL
- SQLite
Testing
I have written some very basic tests, certainly more needs to be done here. If you find this useful please help by testing other databases or writing better unit tests because I must move on.
Issues & Contributing
I will be using this with MySQL in a new API so any issues I find related to my use will be resolved. If you find an issue with MySQL please report it and I will fix it.
If you are using another database and have issues please contribute by submitting a pull request. I do not have time to test this with other database but assume all would work.
betalabs/laravel5-soft-cascade 适用场景与选型建议
betalabs/laravel5-soft-cascade 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19.94k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 04 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 betalabs/laravel5-soft-cascade 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 betalabs/laravel5-soft-cascade 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 19.94k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2017-04-20