where('user_id', $uid) ->exists(); if (!$isExists) { // 不能关注自己 if ($user_follow_id != $uid) { // 关注 $wxLike = new Model(); $wxLike->user_follow_id = $user_follow_id; $wxLike->user_id = $uid; $wxLike->save(); $user = WxUser::where('id', $uid)->first(FieldUtils::userInfoColums()); UserUtils::add_user_notice(4004, $user_follow_id, '新增了一个粉丝', '「' . ''.$user['user_name'].'' . '」悄悄的关注了您。', 101, -$uid); } } DB::commit(); return true; } catch (\Exception $e) { DB::rollBack(); _logger_(__file__, __line__, $e->getMessage()); return false; } } public static function unfollow($uid, $user_follow_id) { DB::beginTransaction(); try { (new Model())->where('user_follow_id', $user_follow_id) ->where('user_id', $uid) ->delete(); DB::commit(); return true; } catch (\Exception $e) { DB::rollBack(); _logger_(__file__, __line__, $e->getMessage()); return false; } } }