vusys/laravel-bitemporal is the only package here I wasn’t directly inspired to write. Rather, I asked ChatGPT to find some ideas for interesting packages, and this is what it suggested to me.
As such, I don’t (yet) have a practical use case for it. But I think the ideas it has are really cool.
This is what it does:
Imagine you’re storing a product’s price. A normal database records one thing: "the price is £12." If it changes, you overwrite it and the old value is gone. Bitemporal storage instead answers two different "when" questions at once:
- When was this true in the real world? (called valid time) – e.g. "the price became £12 on 1 February."
- When did our system actually know it? (called recorded time) – e.g. "we didn’t type that £12 in until 5 February, and on the 10th we realized it was wrong and fixed it."
The reason you need both is corrections to the past. Say on 10 February you discover the price back in February should have been £10, not £12. A normal system just overwrites it, and now it looks like it was always £10 – you’ve destroyed the evidence of what you believed and acted on earlier. A bitemporal system instead keeps the old £12 record and adds the £10 correction, each stamped with when it was true and when you knew it.
That lets you ask questions no ordinary table can answer: "What did we believe the price was on 5 February, at the moment we ran that invoice?" versus "What do we now know the price really should have been?" This matters anywhere you’re not allowed to silently rewrite history – invoices, insurance policies, salaries, tax – because you need to prove what you knew and when you knew it, even after fixing a mistake.
So this package brings that capability to Laravel/Eloquent models, and makes the safe rewriting part (correcting one slice of a timeline without creating overlaps or losing the prior record) automatic.