У меня есть этот Json
файл, который был передан на мой взгляд. Все, что я хочу, это вставить этот Json
файл в мой Yajra Datatable
.
Это пример моего Json Data
, переданного в мое http://127.0.0.1:8000/resolution_time_of_calls
:
{"draw":0,"recordsTotal":205,"recordsFiltered":205,"data":[{"Month":"1","Name":"Analytics Team","Total":"422","AVG":"211.0000","MAX":"212"},{"Month":"1","Name":"Assembly Team","Total":"823","AVG":"137.1667","MAX":"502"},{"Month":"1","Name":"Big Data Team","Total":"5131","AVG":"570.1111","MAX":"985"},{"Month":"1","Name":"Business Intelligence Team","Total":"5706","AVG":"713.2500","MAX":"1127"},{"Month":"1","Name":"Data Security Team","Total":"57703","AVG":"663.2529","MAX":"4463"},{"Month":"1","Name":"Data Security-SouthPH","Total":null,"AVG":null,"MAX":null},{"Month":"1","Name":"Deskside Team","Total":"34841","AVG":"305.6228","MAX":"1498"},{"Month":"1","Name":"Development and Testing
Это мой код в моем resolution_time_of_calls
представлении
<table class="table table-bordered" id="table">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
</table>
<script>
$(function() {
$('#table').DataTable({
processing: true,
serverSide: true,
ajax: '{{ url('getData') }}',
columns: [
{ data: 'Month', name: 'id' },
{ data: 'Name', name: 'name' },
{ data: 'Total', name: 'email' }
]
});
});
</script>
Это мой маршрут:
Route::get('resolution_time_of_calls', 'DisplayDataController@getData');
Мой DisplayDataController
контроллер:
class DisplayDataController extends Controller
{
function getData(){
return datatables(DB::select("SELECT DISTINCT MONTH(DATE_ADD(T.Created, INTERVAL 8 HOUR)) AS Month ,Q. Name
,SUM(TIMESTAMPDIFF(HOUR,T.Created,O.Created)) AS Total
,AVG(TIMESTAMPDIFF(HOUR,T.Created,O.Created)) AS AVG
,MAX(TIMESTAMPDIFF(HOUR,T.Created,O.Created)) AS MAX
FROM rtdb.Tickets T
LEFT JOIN rtdb.Queues Q ON Q.id=T.Queue
LEFT JOIN rtdb.ObjectCustomFieldValues O ON O.ObjectId=T.EffectiveId
AND O.CustomField=15 AND O.ObjectType='RT::Ticket' AND O.Disabled=0
WHERE T.Status!='Deleted' AND T.IsMerged IS NULL AND T.Type='ticket'
GROUP BY MONTH(DATE_ADD(T.Created, INTERVAL 8 HOUR)),Q.Name Order by Month asc
"))->toJson();
}
}
Я хочу такой вывод в моих таблицах данных:
Month| Name |Total
1 | team a | 100
2 | team b | 200
Спасибо !!!