I'm starting to create a CRUD. In the index method of the controller I have put this:
public function index(){
$productos=Producto::get();
return view('productos.index')->with('productos',$productos);
}
And in the index.blade.php view:
foreach($productos as $producto)
echo "<tr>";?>
<td class="text-center">{{$producto->id}}</td>
<td class="text-center">{{$producto->nombre}}</td>
<td class="text-center">{{$producto->precio}}</td>
<td>
<a href="{{ route('producto.show',$producto->id) }}" class="btn btn-info">Ver</a>
</td><?php
echo "</tr>";
Trying to run the application in the browser tells me that it can not find $ products:
"Undefined variable: products (View: C: \ xampp \ htdocs \ ad \ dam2d \ resources \ views \ products \ index.blade.php)"