public function getSectionsForClass(Request $request ,$id )
{
$section = Section::all()->where('clas_id',$id);
return response()->json($section);
}
Мне нужно отправить json на мой взгляд в таблице как
@foreach($section as $sec)
{{$sec->section}}
{{$sec->capacity}}
{{$sec->teacher}}
{{$sec->class}}
@endforeach
Это мой ajax код, в котором я отправил идентификатор и URL
<script type="text/javascript">
$('#select_id').change(function(){
// alert('hello');
var cid = $(this).val();
if(cid){
$.ajax({
dataType: "json",
url: 'section/index/'+cid,
//data: {'class': cid},
type:"GET",
success: function(response){
console.log ((response));
},error: (error) => {
console.log(JSON.stringify(error));
}
});
}
});
</script>
На маршруте
Route::get('admin/section/index/{id}','SectionController@getSectionsForClass');
Заранее спасибо, надеюсь, я получу ответ