I'm trying to retrieve a column and make a sum - using SUM
- according to the time range, but without success. Can you help me with this question?
Detail: I'm not exactly using a table, but I call a function in SQL . The application works well with this function.
Function executed:
Followthesliceofthecontroller
publicfunctionabertura(Request$request,$carteira,$dia,$servico,$segmento){$servico=$servico=='NULL'?null:$servico;$segmento=$segmento=='NULL'?null:$segmento;$data=Date::createFromFormat('Y-m-d',$dia,tz());$servicos=Receptivo::makeSegmento($data->format('Ymd'),$carteira)->orderByRaw('REPLACE(REPLACE(REPLACE(REPLACE(NOME_SERVICO,\'SANTANDER_IN_VAREJO_\',\'\'),\'IN_\',\'\'),\'SERVICE_\',\'\'),\'VAREJO_\',\'\')')->get();$segmentos=Receptivo::makeSegmentoServico(ucfirst(strtolower($carteira)))->selectRaw('distinctsegmento')->get();$datas=collect(range(0,90))->map(function($incremento){returnnow_tz()->copy()->subDays($incremento);});$receb=Receptivo::makeAbertura($data->format('Ymd'),$carteira,$servico,$segmento)->orderBy('Faixa_Horario')->get();//Soma$Query=Receptivo::where('Faixa_Horario','Faixa_Horario')->sum('Atendimento_Cliente_com_Negocio');returnview('reports.hora-a-hora.receptivo.abertura.index',compact('carteira','receb','datas','data','servico','servicos','segmento','segmentos','Query'));}
Excerptfromthemodel:
publicstaticfunctionmakeAbertura($date,$carteira,$servico=null,$segmento=null){/**@varstatic$instance*/$instance=newstatic;$servico=$servico==null?'NULL':"'" . $servico . "'";
$segmento = $segmento == null ? 'NULL' : "'" . $segmento . "'";
$table = sprintf( 'FN_HORA_HORA_RECEPTIVO_SANTANDER_%s_ABERTURA(\'%s\', %s, %s)',
$carteira,
$date,
$servico,
$segmento
);
//dd($table);
return $instance->setTable( $table );
}