I'm having problems sending collections to my blade view. in my controller I have implemented the index function in this way:
public function index(Request $request)
{
$productos = Producto::latest()
->take(5)
->get();
$clientes = Clientes::latest()
->take(5)
->get();
$proveedores = Proveedor::latest()
->take(5)
->get();
$facturas = Factura::latest()
->take(5)
->get();
$facturas_canceladas = Factura::latest()
->take(5)
->get();
//DETERMINAR LOS PRODUCTOS MAS SOLICITADOS
$ventas = Producto::withCount('ventasProductos')
->orderBy('ventas_productos_count', 'desc')
->take(5)
->get();
return view('home')->with('productos', $productos)->with('facturas_canceladas', $facturas_canceladas)
->with('facturas', $facturas)->with('ventas', $ventas)->with('clientes', $clientes)
->with('proveedores', $proveedores);
but this error throws me:
Undefined variable: ventas (View: C:\xampp\htdocs\productos_ventas2\resources\views\home.blade.php)
Check in my view and the sales variable is well set. If I delete this variable, I drag the error to the other variable that follows it, which is clients etc.