laravel-vote icon indicating copy to clipboard operation
laravel-vote copied to clipboard

Is it possible to countVoter with eager loading ?

Open jay7793 opened this issue 7 years ago • 2 comments

image

Is it possible to use this? image

Thank you.

jay7793 avatar Feb 09 '18 06:02 jay7793

Seriously - can someone please add some form of local caching to this package? It's crazy that something as simple as this:

<div id="voteTotal-{{$feature->id}}" data-score-{{$feature->id}}="{{$feature->countTotalVotes()}}">
    {{$feature->countTotalVotes()}}
</div>

means two separate database calls because of the two calls to ->countTotalVotes()

nexxai avatar Oct 20 '18 00:10 nexxai

It doesn't solve your problem fully (caching is more useful) but you could make the best of it by assigning the results to a variable to reuse (psudo code.. Can't remember if @php() is right).

@php($countTotalVotes = $feature->countTotalVotes() )
<div id="voteTotal-{{$feature->id}}" data-score-{{$feature->id}}="{{$countTotalVotes}}">
    {{$countTotalVotes}}
</div>

LunarDevelopment avatar May 07 '19 14:05 LunarDevelopment