Вы должны компактировать с массивами вроде return response()->json(['days' => $days, 'levels' => $levels]);
Контроллер
public function days(Request $request){
$levels=Level::with('lead')->get();
$days=array();
$id = $request->input('months');
$month = $id;
$year = 2018;
for($d=1; $d<=31; $d++) {
$time=mktime(12, 0, 0, $month, $d, $year);
if(date('m', $time)==$month && date('w', $time)>0 && date('w', $time)<6) {
$days[]=date('Y-m-d H:i:s', $time);
}
}
return response()->json(['days' => $days, 'levels' => $levels]);
}
Пример HTML
<table class="table"></table>
JS
Попробуйте вот так:
$(document).ready(function(){
$('.testing').on('change',function(){
var test=$(this).val();
$.ajax({
type:'get',
url:'/days',
data:{"months":test,"_token": "{{ csrf_token() }}"},
success: function(data){
$("#days").empty();
$.each(data['days'],function(index,value){
$("#days").append('<input type="checkbox" checked value="'+value+'" name="days[]" > '+value+'<br/>');
});
$.each(data['levels'],function(key,level){
$("table.table").append(
'<tr>'+
'<td>'+level.id+'</td>'+
'<td>'+level.name+'</td>'+
'</tr>'
);
// added
// if you wish to put all together in one table its up you.
if(level.lead){
$.each(level.lead,function(leadKey,leadValue){
$("table2.table2").append(
'<tr>'+
'<td>'+leadValue.id+'</td>'+
'<td>'+leadValue.name+'</td>'+
'</tr>'
);
});
}
//
});
}
});
});
});