$deposits2 = DB::connection('mysql')
->table('deposits')
->join('users','users.id','=','deposits.user_id')
->select('deposits.*','users.Country')
->where('deposits.status','Approved');
这是我的视图文件中的代码
<script>
$(document).ready( function () {
var table = $('#myTable2').DataTable( {
processing: true,
"serverSide": true,
"ajax": {
"url": "{{url('dashboard/adeposits/json')}}",
"type": "GET"
},
"deferRender": true,
"columns":
[
{ "data" : "id", "title" : "Portfolio#", "searchable": true,
"render": function ( data, type, row, meta ) {
var itemID = data;
return '<a data-toggle="modal" data-target="#DDetailsModal" href="#" onclick="viewDetailsFunc('+row.id+')">D-'+itemID+'</a>';
}
},
{ "data" : "unique_id", "title" : "UserID", "orderable": true, "searchable": true },
{ "data" : "Country", "title" : "Country", "orderable": true, "searchable": true },
答案 0 :(得分:0)
$deposits2 = DB::connection('mysql')
->table('deposits')
->select('deposits.*','users.Country')
->join('users','users.id','=','deposits.user_id')
->where('deposits.status','Approved')
->get();
答案 1 :(得分:0)
在数据表中,您可以在列中设置字段名称。
{ "data" : "Country", name: "users.Country", "title" : "Country", "orderable": true, "searchable": true },