mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Update PollService
This commit is contained in:
parent
2d93bc8b51
commit
f9194df332
1 changed files with 25 additions and 0 deletions
|
@ -63,6 +63,31 @@ class PollService
|
|||
->exists();
|
||||
}
|
||||
|
||||
public static function votedStory($id, $profileId = false)
|
||||
{
|
||||
return !$profileId ? false : PollVote::whereStoryId($id)
|
||||
->whereProfileId($profileId)
|
||||
->exists();
|
||||
}
|
||||
|
||||
public static function storyResults($sid)
|
||||
{
|
||||
$key = self::CACHE_KEY . 'story_poll_results:' . $sid;
|
||||
return Cache::remember($key, 60, function() use($sid) {
|
||||
return Poll::whereStoryId($sid)
|
||||
->firstOrFail()
|
||||
->cached_tallies;
|
||||
});
|
||||
}
|
||||
|
||||
public static function storyChoice($id, $profileId = false)
|
||||
{
|
||||
return !$profileId ? false : PollVote::whereStoryId($id)
|
||||
->whereProfileId($profileId)
|
||||
->pluck('choice')
|
||||
->first();
|
||||
}
|
||||
|
||||
public static function ownVotes($id, $profileId = false)
|
||||
{
|
||||
return !$profileId ? [] : PollVote::whereStatusId($id)
|
||||
|
|
Loading…
Reference in a new issue