send two data in a select in laravel

0

What happens is that I want to send two parameters by means of a json in ajax to the laravel driver, but I do not have the slightest idea of how to select to receive the parameters, I would like them to help me with it Here I leave my driver code

 if ($request->ajax()) {
        if ($request->granja != null && $request->lote != null) {
            $collection = Precebo::join('granjas','granjas.id','=','formulario_precebo.granja_id')
            ->select('granjas.nombre_granja', DB::raw('avg(conversion_ajust_fin)'))
            ->where()
            ->whereBetween('formulario_precebo.fecha_destete',[$request->desde,$request->hasta])
            ->groupBy('granjas.nombre_granja')->get();
        }
        $arrayT = [];
        foreach ($collection as $value) {
            $arrayT[] = [$value->nombre_granja,$value->total];
        }
        return response()->json(['status'=>'success','data'=>$arrayT],200);
    }else{
        abort(402);
    }

I do not know how to make that select to receive the two parameters

    
asked by Juan Esteban Yarce 19.02.2018 в 21:12
source

1 answer

1

No You understand your question very well but I think what you want is something like the following:

$collection = Precebo::join('granjas','granjas.id','=','formulario_precebo.granja_id')
        ->select('granjas.nombre_granja', DB::raw('avg(conversion_ajust_fin)'))
        ->where('granjas.nombre_granja',$request->granja)
        ->where('formulario_precebo',$request->lote)
        ->whereBetween('formulario_precebo.fecha_destete',[$request->desde,$request->hasta])
        ->groupBy('granjas.nombre_granja')->get();
    
answered by 19.02.2018 / 21:21
source