owen-it / laravel-auditing

Record the change log from models in Laravel
https://laravel-auditing.com
MIT License
3.05k stars 390 forks source link

Support for testing time travel / Carbon's setTestNow #801

Closed Braunson closed 1 year ago

Braunson commented 1 year ago
Q A
Bug? no
New Feature? yes
Framework Laravel
Framework version 9.52.2
Package version 13.1.0
PHP version 8.1.6

Feature Details

Support for Laravel's time travel feature in tests / Carbon::setTestNow() for audits.

Example Code

$model = Model::create();

$this->travel(-30)->days(); // or $this->travelTo(now()->subDays(30));

$model->delete();

$this->travelBack();

After checking the audit's created_at timestamp they are the current date time and not -30 days.

Braunson commented 1 year ago

Seems something funky locally was going on and this is a non-issue. Closing.