-
If I use laravel-activitylog how can I get list of inactive users for period of dates? |
Beta Was this translation helpful? Give feedback.
Answered by
Gummibeer
May 10, 2020
Replies: 1 comment
-
If your user model uses this trait https://github.com/spatie/laravel-activitylog/blob/master/src/Traits/CausesActivity.php you can use the $avtiveUsers = User::whereHas('actions', fn(Builder $q) => $q->where('created_at', '>=', now()->subWeek()))->get(); This will return all users with at least one activity in the last week. You can invert the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Gummibeer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If your user model uses this trait https://github.com/spatie/laravel-activitylog/blob/master/src/Traits/CausesActivity.php you can use the
actions()
relationship and use thecreated_at
column.This will return all users with at least one activity in the last week. You can invert the
whereHas()
to get all inactive or change the carbon date to adjust the period to check.It's a normal eloquent relationship so you can do whatever you want on the query.