Call to undefined method Illuminate \ Database \ Query \ JoinClause :: whereBetween () Laravel 5.2

0

I'm having this error in my query, I've already identified that the use of whereBetween within a function join is impossible to use, but I saw that staff could use DB::Raw and replace that whereBetween %.

The point is that I did not find any examples of using DB::Raw within function join and the forms I tried were not successful.

Code:

$exec = DB::table('execucao_acompanhamento as a')
        ->join('execucao_acompanhamento_busca_bens as h', function($join)
                                          use($data_busca_1_1, $data_busca_1_2){
            $join->on('a.id','=','h.acompanhamento_id')
                ->where('h.busca_bens_id','=','1')
                ->whereBetween('h.data_busca', ["$data_busca_1_1","$data_busca_1_2"]);
        })
        ->get();
    
asked by anonymous 28.09.2017 / 20:13

1 answer

0

I've been looking at other forums and found how to replace whereBetween. It was like this.

$exec = DB::table('execucao_acompanhamento as a')
->join('execucao_acompanhamento_busca_bens as h', function($join) use($data_busca_1_1, $data_busca_1_2){
    $join->on('a.id','=','h.acompanhamento_id')
        ->where('h.busca_bens_id','=','1')
        ->where('j.data_busca','>=', $data_busca_1_1)
        ->where('j.data_busca','<=', $data_busca_1_2);
})
->get();
    
28.09.2017 / 20:54