subDays($purgeDays); $evaluator = new UserInactivityEvaluator; User::query() ->where('roles_id', UserRole::USER->value) ->where('created_at', '<', $threshold) ->chunkById(100, static function ($users) use ($evaluator, $threshold): void { $users ->filter( static fn (User $user): bool => $evaluator->shouldPurge( createdAt: $user->created_at, updatedAt: $user->updated_at, lastLoginAt: $user->lastlogin, apiAccessAt: $user->apiaccess, lastDownloadAt: $user->lastdownload, grabs: $user->grabs, threshold: $threshold, ) ) ->each(static fn (User $user) => $user->delete()); }); } }