/** * 是否已经反对帖子. * * @param $topic_id * @param $user_id * * @return bool */ public function userDownVoted($topic_id, $user_id) { return Vote::query()->where(['user_id' => $user_id, 'votable_id' => $topic_id, 'votable_type' => 'Topic', 'is' => 'downvote'])->exists(); }
/** * 是否已经反对帖子. * * @param $topic_id * @param $user_id * * @return bool */ protected function isDownVoted($topic_id, $user_id) { return Vote::where(['user_id' => $user_id, 'votable_id' => $topic_id, 'votable_type' => 'Topic', 'is' => 'downvote'])->exists(); }