По такому пути на сайт
localhost:8000/index выдает ошибку
Undefined variable: product (View: D:\OpenServer\domains\sportgoods\resources\views\index.blade.php)
Это весь мой контроллер
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Product;
class ProductController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$products = Product::all();
return view('products.index', compact('products'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('products.create');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$product = Request::all();
Product::create($product);
return redirect('products');
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$product = Product::find($id);
return view('products.show', compact('product'));
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$product = Product::find($id);
return view('products.edit', compact('product'));
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$productUpdate = Request::all();
$product = Product::find($id);
$product->update($productUpdate);
return redirect('products');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
Product::find($id)->delete();
return redirect('products');
}
}
А вот блок на который он ругается
<div class="col-sm-3 col-md-3">
<div class="block thumbnail">
<img src="img/product.png" alt="..." class="image-responsive">
<div class="caption">
<h3>Thumbnail label</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid delectus facere harum in ipsam perferendis quisquam. Culpa earum, excepturi exercitationem illum ipsam minus nobis perspiciatis provident quasi recusandae rerum voluptatem.</p>
@if(Auth::check() && (Auth::user()->is_admin))
<a href="{{ route('products.edit', $product->id) }}" class="btn btn-success">Редактировать</a>
<a href="{{ route('products.destroy', $product->id) }}" class="btn btn-danger">Удалить</a>
@endif
</div>
</div>
</div>