@php $selected = array(); $table = 'App\Models\Permissions'; foreach($permission_exist as $pe) { $selected[]= $pe->permission_id; } @endphp @foreach($menu as $k=> $m) @php $query= $table::where('menu_id',$m->menu_id)->get(); $count_menu = count($query); @endphp @if($m->menu_url != '#') {{$m->menu_name}} All @foreach($query as $val) id,$selected)) ? "checked" : ""}} > {{$val->display_name}} @endforeach @endif @endforeach