Good evening I'm using laravel 5.6 and I want to make a data request by ajax using an id and with this I get the result of two queries. My questions is how I can respond to the ajax request with the result of the consultations.
These are my questions that are in the controller:
$compras =DB::table('compras')
->join('proveedors', 'compras.id_proveedor', '=', 'proveedors.id_proveedor')
->select('id_compra','proveedors.nombre AS Empresa','fecha_compra','descripcion','estado')
->where('id_compra', '=', $id)
->get();
$inventario=DB::table('inventarios')
->join('tipo_materials', 'inventarios.id_tipo_material', '=', 'tipo_materials.id_tipo_material')
->join('almacens', 'inventarios.id_almacen', '=', 'almacens.id_almacen')
->select('id_item','tipo_materials.descripcion AS Material','rango_inicial','rango_final','serie','cantidad','precio_unitario','observaciones','almacens.descripcion AS Almacen')
->where('id_compra', '=', $id)
->get();
How could this answer return?
return response()->json(
??????????
);