geeky/historical-model
Composer 安装命令:
composer require geeky/historical-model
包简介
This package is to make a historical model for any model you want very easy and very quickly.
README 文档
README
Installation
Install using composer:
composer require geeky/historical-model --dev
About
This package created for helping you to create a historical model/data for any model/data you want, so one of the solutions of creating a historical data os by creating a history table for the basic table, so if we have a table called employees with this columns:
- id
- name
- salary
- address
- created_at
- updated_at
and we want to make save our data in another place in case if the employee changes his address or his salary for example, like if the salary of an employee is 500$ then he updated the salary to be 1000$ then 1500$ so we want to save all of these data to have a historical data to know when the employee was 1000$ or something else, Our history table schema will be:
- id - primary key. Detail/historical id
- master_id - for example in this case called 'employee_id', this is the FK to the Master record
- start_datetime - timestamp indicating the start of that database row
- end_datetime - timestamp indicating the end of that database row
- status control - single char column indicated status of the row. 'c' indicates current, NULL or 'a' would be historical/archived. We only use this because we can't index on END_DATETIME being NULL
- created_by_id - stores the ID of the account that caused the row to be created
- the_columns_you_choose_to_log - stores the actual data
Usage
you can create the historical model/data just by a very easy command
php artisan make:history-model
then you will be asked what model you want to make it historical,
and the package will automatically get your columns and ask you column column with y/n if you to log it, and hola you will get your model and your migration file ready to migrate.
Important
You should use the
Geeky\Historical\Concerns\Historicaltrait file in your base model
Todo List
- Add a command to sync the base data from the base table to the historical table
- Add the trait automatically to the base model
- Remove the timestamps() from the migration file
geeky/historical-model 适用场景与选型建议
geeky/historical-model 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 07 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「model」 「laravel」 「history」 「historical」 「historical model」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 geeky/historical-model 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 geeky/historical-model 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 geeky/historical-model 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
An improved history backend module for Neos
Implementation of the Omnibus Directive for Sylius application.
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Manage a history of your models simply by adding a package for Laravel
Interfaces for web resource models and services to retrieve and create them
Laravel 5 - Repositories to the database layer
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-07-18