In the database there are two tables and organized connection between them belongsToMany ("many-to-many") through a staging table, for example, users (Users), groups (Community) and the junction table group_user.
How do I display a list of checkbox-owls all Communities of the site, with a marked checkbox-AMA, for a specific User, if he is in the community.
Did so, but this option does not work correctly
@foreach ($groups as $group)
@foreach (@user->groups as $user_group)
@if ($user_group->id == $group->id)
<input type="checkbox" checked>$group->title
Cycle in a loop and then test the condition as it is not very much.
Maybe there is some method that would simplify the check of one model to another? He still can't understand(