id == $follower->id, '不能关注自己'); /** @var CustomerFollow $cf */ $cf = CustomerFollow::withTrashed()->where('follower_id', $follower->id) ->where('customer_id', $customer->id) ->first(); if (!$cf) { $cf = new CustomerFollow(); $cf->customer_id = $customer->id; $cf->follower_id = $follower->id; $cf->save(); } else { if ($cf->trashed()) { $cf->restore(); } else { $cf->delete(); } } // 刷新关注人数和粉丝数 $customer->refreshFollowerFans(); $follower->refreshFollowerFans(); } }