How to return data array with join in Laravel with DB class?

0

I need help with this SQL of Laravel :

$process = $db->table('processo')->where('nrprocesso',$id)
 ->leftJoin('viatransporte', function($viatransporte){
      $viatransporte->on('processo.idviatransporte', '=', 'viatransporte.idviatransporte')
      ->whereNotNull('processo.idviatransporte'); })
 ->leftJoin('area', function($area){
     $area->on('processo.idarea', '=', 'area.idarea')
      ->whereNotNull('processo.idarea'); })
 ->leftJoin('moeda', function($moeda){
     $moeda->on('processo.idmoedamle', '=', 'moeda.idmoeda')
       ->whereNotNull('processo.idmoedamle'); });    

This join needs to return two records that are in the database, but returns only one record, the first, the others do not. How do I return an array with all records?

->leftJoin('processodocinstrucaodespacho', function($processodocinstrucaodespacho){
  $processodocinstrucaodespacho->on('processo.idprocesso',
                  '=', 'processodocinstrucaodespacho.idprocesso')
     ->where('processodocinstrucaodespacho.iddocinstrucaodespacho', '=', 1); })

->select('processo.*', 'area.aparea', 
         'viatransporte.nmviatransporte', 'moeda.sigla',
         'processodocinstrucaodespacho.nrdocinstrucaodespacho')
->get();  
    
asked by anonymous 19.03.2017 / 16:03

1 answer

-2
$process = $db->table('processo')->where('nrprocesso',$id)
 ->leftJoin('viatransporte', function($viatransporte){
      $viatransporte->on('processo.idviatransporte', '=', 'viatransporte.idviatransporte')
      ->whereNotNull('processo.idviatransporte'); })
 ->leftJoin('area', function($area){
     $area->on('processo.idarea', '=', 'area.idarea')
      ->whereNotNull('processo.idarea'); })
 ->leftJoin('moeda', function($moeda){
     $moeda->on('processo.idmoedamle', '=', 'moeda.idmoeda')
       ->whereNotNull('processo.idmoedamle'); })->get()->toArray(); 

For more information: link

    
24.12.2018 / 16:08