【发布时间】:2019-04-10 06:50:24
【问题描述】:
很难在刀片视图中显示与会者表中的数据,但在浏览器的网络中显示。在刀片中,它只显示主要模型是活动,并且来自参加者的数据只输出对象。
我需要输出与会者的数据
例如attendee.fname
这是我的ajax
$(document).ready(function(){
$('#student_table').DataTable({
"processing": true,
"serverSide": true,
"ajax": "{{ route('ajaxdata.getdata') }}",
"columns":[
{ data: "ActivityID" },
{ data:"attendee",name:"attendee.fname" } //cant show this need help
]
});
//Heres my controller
function getdata()
{
// $students = Student::select('first_name', 'last_name');
// return Datatables::of($students)->make(true);
//$qr = QR::select('ActivityID', 'AttendeesID');
// return Datatables::of($qr)->make(true);
// $att = Attendee::select('fname','lname')->get();
$qr = QR::with('attendee')->get();
return Datatables::of($qr)->make(true);
}
});
Heres my relationship
public function attendee()
{
return $this->hasMany('App\Attendee','user_id','AttendeesID');
}
public function qr()
{
return $this->belongsTo('App/QR','AttendeesID','user_id');
}
【问题讨论】: