Answer the question
In order to leave comments, you need to log in
Get list of db field values by array in Laravel 5.2?
Good afternoon. The site displays a list of values, each has a checkbox. I got the organization id and I'm trying to list the category in the edit method. Naturally, I need to set checked to the categories that are active. Categories are rendered like this:
@foreach($places_categories as $place_category)
<div class="checkbox">
<input {{ in_array($place_category->id, [1,2,3,4]) ? 'checked' : '' }} type="checkbox" ... >
</div>
@endforeach
$place = Place::find($id);
$my_places = $place->with('categories')->get();
{{ in_array($place_category->id, [1,2,3,4]) ? 'checked' : '' }}
, however, it is not possible to get the list of values as an array. Is there any regulated way to solve the problem, please tell me, or some other method. If there are questions you don't understand, ask. I will be very grateful for your help.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question