$type, 'user_id' => $user->id, 'points' => $points, 'old_points'=> $user->userInfo->points, 'desc' => $desc, ]); if ($points > 0) { $user->userInfo()->increment('points', abs($points)); } else { $user->userInfo()->decrement('points', abs($points)); } $res = true; } return $res; } }