I was wondering if there is a function or something else where you can get a different element from the collection than the primary key ... For example, if the voices have the foreign key 'user_id', how can I check this? The laravel document was just an example of checking the primary key with contains (). Can anyone help me out?
An example that checks if there is a vote with id = 2
@foreach($projects as $project) @if ($project->votes->contains(2))
I would like something to check if there is a vote that has user_id = = id in user id
@foreach($projects as $project) @if ($project->votes->contains('user_id' == Auth::id()))
source share