Why is my variable not found?

Trying to pass from controller to view products from the database.

Controller:
public function index()
{
 $allProducts = Product::all();

 return view('index', compact('allProducts'));
 }

View:
@foreach( $allProducts as $product )
 <img src="img/product.png" alt="..." class="image-responsive">
 <div class="caption">
 the <h3>{{ $product->title }}</h3>
 <p>{{ $product->description }}</p>
</div>
@endforeach

Routes:
Route::get('index', function() {
 return view('index');
});


And displays this error
7812ba6416704aa8ad159a61f65e9dc8.png
After all, all the same is done correctly?
July 9th 19 at 14:06
1 answer
July 9th 19 at 14:08
Solution
You can get conclude view function and not the direction of action controller
Thank you very much, totally forgot about this. - Jo_Schowalter commented on July 9th 19 at 14:11

Find more questions by tags LaravelPHP