isBinded($data['bind_type'], $data['source_id'], $data['user_id'])) { return $res; } return UserRelationBind::query()->updateOrCreate( ['bind_type' => $data['bind_type'], 'source_id' => $data['source_id'], 'user_id' => $data['user_id']], ['json_data' => $data['json_data']] ); } public function isBinded($bind_type, $source_id, $user_id) { return UserRelationBind::query() ->select('id') ->where(['bind_type' => $bind_type, 'source_id' => $source_id, 'user_id' => $user_id]) ->first(); } }