I didn't know why undefined variable
, I've made controller, model and view. I've included the compact in the controller for the variable.
this is my controller
public function product(){
$products = Product::all();
// print_r($products);
return view('views.product', compact('products'));
}
model
class Product extends Model{
protected $fillable = ['product_name', 'price', 'kategori'];
}
and view
@foreach ($Products as $post)
<tr>
<td>{{$post->product_name}}</td>
</tr>
@endforeach
route
Route::get('/product', 'AdminController@product')->name('Product');
Please help me I don't know why this undefined variable, cause I've included compact in my controller