php - Laravel Checking If A Collection Contains A Foreign Key -


i wondering if there function or else, can other element collection primary key... example if votes have foreign key 'user_id', how check this? on laravel doc there example check primary key using contains(). can me out?

example checks if there vote id = 2

@foreach($projects $project)   @if ($project->votes->contains(2))   //   @endif @endforeach 

i want check if there vote has 'user_id' = signed in users id

@foreach($projects $project)   @if ($project->votes->contains('user_id' == auth::id()))   //   @endif @endforeach 

if ($votes->contains('user_id', auth()->id())) {     // } 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -