数据未显示在视图页面中。视图页面已加载,但数据未传递。作为我的第一个 Laravel 项目,我找不到错误?如果有人帮忙解决,那将是一个很大的帮助。CartController.phpuse Illuminate\Http\Request;use App\Product;use App\Category;class CartController extends Controller{ public function index() { $product = Product::get(); return view ('cart')->with(compact('products')); } public function show($id) { $product = Product::find($id); return view('cart')->with(compact('product')); }} 购物车.blade.php@foreach($product as $p) <tr class=""> <td class="d-none d-md-table-cell"> <a href="#"><img class="img-fluid max-width-100 p-1 border border-color-1" src="{{asset('/storage/admin/'.$p ['prod_image_path'] ) }}" alt="Image Description"></a> </td> <td data-title="Product"> <a href="#" class="text-gray-90">{{ $p ['prod_name'] }}</a> </td> <td data-title="Price"> <span class="">LKR {{ $p ['prod_price'] }}.00</span> </td> </tr>@endforeach网页.phpRoute::get('/cart', 'CartController@index')->name('cart');Route::get('/cart/{id}', 'CartController@show')->name('cart');
- 2 回答
- 0 关注
- 119 浏览
添加回答
举报
0/150
提交
取消