I'm facing a problem that all checkboxes are checked. I want only the checkbox which has a value in database to be checked.
I have these three tables where place_category is the pivot table
------- -------------- ----------
places place_category categories
------ -------------- ----------
id place_id id
name category_id name
eloquent relationships are set.
Here I'm trying to associate many categories for one place but I want only the categories that I added to that place to be checked in the checkbox.
...........
@foreach($categories as $category)
<div class="col-lg-3">
<div class="form-group">
<input type="checkbox" name="category[]" value="{{$category->id}}" {{isset($category) ? 'checked': '' }} >{{ $category->name }}<br>
</div>
</div>
@endforeach
Is there any problem with my condition ? {{isset($category) ? 'checked': '' }}