hasOne(User::class, 'id', 'other_user_id'); } /** * 获取我拉黑的用户和拉黑我的用户ids * @param $user_id * @return mixed */ public function getBlackIds($user_id) { $ids = self::where('user_id', $user_id)->pluck('other_user_id')->toArray(); $other_ids = self::where('other_user_id', $user_id)->pluck('user_id')->toArray(); return array_merge($ids, $other_ids); } }