I have a query, but sometimes this query returns an empty value ( no records ).
These query results are directed to the generation of a HighCharts chart, but when there are no values within the query, the graph is not generated.
My idea would be to set a if
whenever the query returned empty, but I can not.
$vel_a2 = DB::table('ocorrencias')
->select(DB::raw('count(*) as qnt_cnt, velocidade'))
->where('cliente',$request->cliente)
->where('velocidade','=','A2')
->groupBy('velocidade')
->get();
if(empty($vel_a2))
{
$vel_a2 = array('qnt_cnt'=> 0, 'velocidade'=>'A2');
}
Whenever the query is empty, it will assume a array
to send to the chart.