Any way to modify charts to only return a subset of data?

I'm attempting to create a user activity chart and presently have users organized into smaller sub-sets. I wondered if there was a way to only show chart results for users within the same user's sub-set list? For example

... // the widget
[$users, $months] = $this->getPerMonth();
... // rest of widget


private function getPerMonth(): array
    {
        $activity = UserActivity::get()->where('organizations_id', auth()->user()->organizations_id); // not in use currently
        $data = Trend::model(UserActivity::class)
            ->between(
                start: now()->startOfYear(),
                end: now()->endOfYear(),
            )
            ->perMonth()
            ->count();

        return [
            $data->map(fn (TrendValue $value) => $value->aggregate),
            $data->map(fn (TrendValue $value) => now()->rawParse($value->date)->format('M')),
        ];
    }

I'm wondering if there is a way to use the
$activity
variable somehow instead of the class? Or can I filter it after the values are returned from getPerMonth?
Thanks in advance!
Solution
You just used the get() in the wrong order.
Was this page helpful?