0
セレクタでforeachで$ selected_studentにする必要があります。すべての列をすべての尊敬のstudent_idで選択し、データテーブルを表示する必要があります(同じことをしておらず、エラーを出していません)。laravelのコントローラでForeach 5.2
私はyajra datatableを使用しています。
コントローラあなたの場合、これは構造またはforeach
ループで
エラーがforeach
ループ内にある
public function anyData(Request $request)
{
$selected_batch_value = Session::get('batch_selection');
$select_student = DB::table('student_batch')
->select('student_id')
->where('batch_id', '=', $selected_batch_value)
->get();
if($selected_batch_value != 0) {
foreach($select_student as $select_student) {
$student[] = student::select('student_id', 'first_name','middle_name','last_name', \DB::raw('CONCAT(first_name, " ",middle_name, " " ,last_name) AS full_name'), 'mobile_num', 'email','address_line1','address_line2','state','city','pincode',\DB::raw('CONCAT(address_line1, "<br>",address_line2, "<br> " ,state, "<br>",city,"<br>",pincode) AS address'))
->where('student_id', '=', $select_student->id)
->get();
}
return Datatables::of($student)->make(true);
} else {
$student = student::select('student_id', 'first_name','middle_name','last_name', \DB::raw('CONCAT(first_name, " ",middle_name, " " ,last_name) AS full_name'), 'mobile_num', 'email','address_line1','address_line2','state','city','pincode',\DB::raw('CONCAT(address_line1, "<br>",address_line2, "<br> " ,state, "<br>",city,"<br>",pincode) AS address'));
return Datatables::of($student)->make(true);
}
}
'foreach($ select_student as $ select_student)'とは何ですか?それは愚かです、 'foreach'ループに関する記事をお読みください。 – ventaquil