Why validation in Laravel happens only the first time?

All good.
You have a table with recipes and table with users and the table "favourites" - which is the user id and the id of the recipe.

On the main page displays the actual recipes
in the template of the index page
@foreach ($recipeCards as $recipeCard)

and plug-in the template of the recipe is this check
@if (Auth::check())
 <?php $count = Favorite::where('dishId', '=', $recipeCard--->id)->where('id', '=', Auth::user()->id)->count(); ?>
 @if ($count <> 0)
 <li class="favorite black"></li>
 <li class="note gray"></li>

ie if the recipe in the user's favorites is the black icon, if not, grey.

Why is $count == 1 only under the condition that the first output recipe to favorites, and only for him.
In other cases, $count == 0. Why - to understand so far and failed.
September 19th 19 at 12:11
1 answer
September 19th 19 at 12:13
Maybe because you Auth::user()->id is compared with id, and it is necessary with some of the user_id?
Brilliant!.. The mistake hadn't noticed. - marie commented on September 19th 19 at 12:16

Find more questions by tags Laravel