Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to manually set created at date #622

Merged
merged 5 commits into from
Feb 22, 2020

Conversation

chrisrhymes
Copy link
Contributor

First, just wanted to say this is a great package, but I was wondering if it is possible to set a custom created_at date for an activity? My initial use case was actually for testing as I want to test my application logic where it will not send a notification if there is an existing "reminder" activity within the last 2 weeks.

The way I got around this in the unit test is to use the following:

$now = now();
Carbon::setTestNow(now()->subDays(15));
activity()->performedOn($model)->log('reminder');
Carbon::setTestNow($now);

But I thought it would be nice to do something like this to specify the log created at date:

activity()->performedOn($model)->createdAt(now()->subDays(15))->log('reminder');

// or
activity()->performedOn($model)->at(now()->subDays(15))->log('reminder');

This could be useful for manually logging activities that are not captured in the system (something done "offline") at a different date/time than the user logs it in the system.

Copy link
Collaborator

@Gummibeer Gummibeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this complete PR - including documentation and test! 😊

src/ActivityLogger.php Outdated Show resolved Hide resolved
src/ActivityLogger.php Outdated Show resolved Hide resolved
@Gummibeer
Copy link
Collaborator

Thanks - I will release it during this week.

@ArnaudLier
Copy link

@Gummibeer The week's a little overwhelming

@Gummibeer Gummibeer merged commit 1625e53 into spatie:master Feb 22, 2020
@Gummibeer
Copy link
Collaborator

@chrisrhymes sorry for the delay! And @ZeProf2Code thanks for the reminder.
Sometimes it's hard to keep track of open tasks.
https://github.com/spatie/laravel-activitylog/releases/tag/3.10.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants