2
I can pass 2 json_encode in a single function in the Laravel?
 What is the best way to return 2 JSON different?
Where 1 consults the table Products and the other the table States.
Look at this controller of mine:
   $data = Produtos::select(
                      DB::raw('nome as nome'),
                      DB::raw('count(*) as number'))
                    ->groupBy('nome')
                    ->get();
    $array[] = ['Nome', 'Number'];
    foreach ($data as $key => $value) {
      $array[++$key] = [$value->nome, $value->number];
    }
    /**
    * CALCULO DOS ESTADOS
    */
    $estados = Estados::selectRaw('SUM(valor) as valor, estado as estado')->groupBy('estado')->get();
    $arrayEstados[] = ['Valor', 'Estado'];
    foreach($estados as $key => $valor) {
        $arrayEstados[++$key] = [$valor->valor, $valor->estado];
    }
    return view('home', compact('notasEntrada', 'notasSaida', 'valorNotasEntrada', 'valorNotasSaida'))->with('nome', json_encode($array), 'estados', json_encode($arrayEstados));
}
Note that in the return view I’m passing 2 json_encode but I am not having result, this is allowed to do? What is the best solution?
I’ll try, I’ll get back to you @Bulfaitelo
– Cristiano Facirolli
It worked @Bulfaitelo, thanks for your help!
– Cristiano Facirolli