PHPackages                             kdabrow/time-machine - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. kdabrow/time-machine

ActivePackage[Testing &amp; Quality](/categories/testing)

kdabrow/time-machine
====================

Laravel / Lumen library that allows to change dates in db

1.2.0(2y ago)56.1k2MITPHPPHP ^7.2|^8.0

Since Jun 15Pushed 2y ago1 watchersCompare

[ Source](https://github.com/karoldabro/time-machine)[ Packagist](https://packagist.org/packages/kdabrow/time-machine)[ RSS](/packages/kdabrow-time-machine/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (2)Versions (9)Used By (2)

[![GitHub Workflow Status (branch)](https://github.com/karoldabro/time-machine/actions/workflows/laravel.yml/badge.svg)](https://github.com/karoldabro/time-machine/actions/workflows/laravel.yml/badge.svg)[![Packagist Version](https://camo.githubusercontent.com/cb2a4a8161f87bf984f1f471a7646c1e0ba2ca20fa5621ca7886e3cdbe248640/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b646162726f772f74696d652d6d616368696e65)](https://camo.githubusercontent.com/cb2a4a8161f87bf984f1f471a7646c1e0ba2ca20fa5621ca7886e3cdbe248640/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b646162726f772f74696d652d6d616368696e65)[![Packagist Downloads](https://camo.githubusercontent.com/f1cf617f60c0b8e1f051675a8e52e650b51a05086c43e571e95146a967a9e81a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6b646162726f772f74696d652d6d616368696e65)](https://camo.githubusercontent.com/f1cf617f60c0b8e1f051675a8e52e650b51a05086c43e571e95146a967a9e81a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6b646162726f772f74696d652d6d616368696e65)

Time machine
============

[](#time-machine)

This package allows to move in time database data. It automatically selects all fields that store datetime and move them by given period or to particular date, relatively from it current value. See example to check more details.

Motivation
----------

[](#motivation)

This package might be useful in a pre-prod environment to test log lasting processes. For example generating customer invoice. Usually invoices are generated in a 30 days period. You might move
customer and all it's data into previous invoice cycle (30 days in to past) and effectively simulate whole invoice cycle like that customer was created 30 days ago.

Installation
------------

[](#installation)

First install main package:

```
composer require kdabrow/time-machine
```

Then install database driver package:

DatabaseDrivermysql`composer require kdabrow/time-machine-mysql `postgres`composer require kdabrow/time-machine-postgres `Advice is to install those packages as --dev dependencies.

Usage
-----

[](#usage)

### Time traveller setup

[](#time-traveller-setup)

First create TimeTraveller. Only Eloquent model can be TimeTraveller. Basic configuration look like this:

```
