braankoo/eloquent-snapshot
Composer 安装命令:
composer require braankoo/eloquent-snapshot
包简介
Laravel Eloquent Snapshot is a lightweight package that enables automatic or manual snapshots of Eloquent model states. Ideal for audit trails, change tracking, or rollback functionality, this package stores historical records of model data in a flexible and efficient way.
README 文档
README
Eloquent Snapshot is a Laravel package that provides functionality for storing and restoring snapshots of Eloquent models. This is useful for tracking changes, creating backups, or implementing undo functionality in your application.
Installation
Install the package via Composer:
composer require braankoo/eloquent-snapshot
Usage
Storing Snapshots
Use the EloquentSnapshotStoreService to store snapshots of Eloquent models:
use Braankoo\EloquentSnapshot\EloquentSnapshotFacade as Snapshot; Snapshot::create($model); Snapshot::create([$model1, $model2]); Snapshot::create(collect([$model1, $model2]));
Restoring Snapshots
Use the EloquentSnapshotRestoreService to restore snapshots of Eloquent models:
use Braankoo\EloquentSnapshot\EloquentSnapshotFacade as Snapshot; use Braankoo\EloquentSnapshot\EloquentSnapshotFilter; Snapshot::restore(Model::first()); // Restore the last model snapshot Snapshot::restore(Model::first(), (new EloquentSnapshotFilter())->first()); Snapshot::restore(Model::first(), (new EloquentSnapshotFilter())->latest());
Filtering Snapshots
You can filter snapshots using the EloquentSnapshotFilter class:
use Braankoo\EloquentSnapshot\EloquentSnapshotFilter; use Braankoo\EloquentSnapshot\EloquentSnapshotFacade as Snapshot; Snapshot::restore(Model::first(), (new EloquentSnapshotFilter())->before(Carbon::now()->subDays(7))->after(Carbon::now()->subDays(30))->first());
Features
- Store snapshots of Eloquent models, arrays, or collections.
- Restore snapshots with optional filtering.
- Transactional operations for data integrity.
- Supports chunked inserts for large datasets.
Configuration
No additional configuration is required. The package uses Laravel's default database connection. All you have to do is run the migrations to create the necessary tables:
php artisan migrate
Contributing
Contributions are welcome! Please submit a pull request or open an issue for any bugs or feature requests.
License
This package is open-source and licensed under the MIT License.
braankoo/eloquent-snapshot 适用场景与选型建议
braankoo/eloquent-snapshot 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 braankoo/eloquent-snapshot 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 braankoo/eloquent-snapshot 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-14