@foreach ($modules as $index => $module2)
@php
$functions = DB::table('app_modules')->where('module_id_fk',$module2->id)->select('id','name')->orderBy('name')->get();
@endphp
{!! Form::checkbox('checkAll', null, false,['class'=>'checkAll',"style" => "margin-left: 5px"]) !!}
{!! Form::label($module2->name,'Check/Uncheck All') !!}
@foreach($functions as $function)
{!! Form::checkbox("modulesIds[]", $function->id, false,['moduleId'=>$module2->id,'functionId'=>$function->id,'class'=>'checkItem']) !!}
{!! Form::label($function->name,$function->name) !!}
@endforeach
@endforeach