You should move this logic out of blade. But anyways, you are missing get/first or similar (using exists() in my example)
!App\Models\Socialog::where('question_id', $socialog->question_id)->where('token', $socialog->token)->exists())
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, i have socialogs table and it's have question_id and token columns. I need if someone already voted then button must display but if he didn't voted button should appear.
@foreach($socialogs as $socialog)
@endforeach
@if(!App\Models\Socialog::where('question_id', $socialog->question_id)->where('token', $socialog->token))
<button type="submit" class="btn btn-primary">Vote</button>
@endif
But it's displayed button in all votes.
@spAo it should be simple but I am very confused by you logic. You get all sociolog which are all that are voted on? And then want to check if they are voted on?
If you make a list of people with brown hair, then how would you use that list to check if they have brown hair? They will all have brown hair
And the naming is strange. Normally a model that has something to do with votes would be named as such
Please or to participate in this conversation.