Good evening, could someone please help me on this: I made a select and gave a "get ()" at the end to get the results, I passed them in an array that I'm getting in a function via ajax:
$table = DB::table('empenho as emp')
->join('gestora', 'emp.unidGestId', '=', 'gestora.id')
->join('gestora_tipo', 'gestora.tipoId', '=', 'gestora_tipo.id')
->join('despesa', 'emp.fichaOrcId', '=', 'despesa.id')
->join('pessoa', 'emp.fornecedorId', '=', 'pessoa.id')
->join('sub_elemento', 'emp.subElementoId', '=', 'sub_elemento.id')
->join('fonte', 'emp.fonteId', '=', 'fonte.id')
->join('siops', 'emp.siopsId', '=', 'siops.id')
->join('cbo', 'emp.cboId', '=', 'cbo.id')
->select('gestora_tipo.nome as a', 'emp.nrEmpenho as b', 'emp.date as c', 'emp.hora_insc as d',
'emp.valor as e', 'pessoa.nome as f', 'sub_elemento.codSubElem as g', 'despesa.valor as h',
'fonte.descricao as i', 'emp.historico as j', 'emp.tipo as k', 'siops.descricao as l',
'cbo.descricao as m', 'emp.folha as n')->get();
$header = ['Gestora', 'Número', 'Data', 'Hora', 'Valor', 'Credor', 'SubElemento',
'Despesa', 'Fonte', 'Historico', 'Tipo', 'Siops', 'CBO', 'Folha'];
return ['Tipo' => 'Empenho', 'header' => $header, 'table' => $table, 'id' => $id];
However, I am not able to show the result containing the fields filled with database values, when I do a for ajax it takes up the variable $ header, but does not get the $ table, I can not do this return work, could someone tell me what I'm wrong?
function retornaEmpenho(json){
var result= $('<div>');
for(var i = 0; i < json.header.length; i++)
{
var divInner = $('<div>');
divInner.addClass(json.header[i]);
divInner.append(json.header[i]+': '+json.table[i]);
result.append(divInner);
}
When I do this, I throw in the fields with the values, the header works (of course), but the $ table does not return the right value, just an "undefined" value, somebody help me please! Thank you in advance.