public function activities($accountId, $userId, $viewAll)
{
$activities = Activity::where('activities.account_id', '=', $accountId)->where('activities.activity_type_id', '>', 0);
if (!$viewAll) {
$activities = $activities->where('activities.user_id', '=', $userId);
}
return $activities->orderBy('activities.created_at', 'desc')->with('client.contacts', 'user', 'invoice', 'payment', 'credit', 'account', 'task', 'expense', 'contact')->take(50)->get();
}