Php 我需要惠特·拉瓦弗的帮助
你好,为什么我会出现这个错误 我需要小小的帮助 有错误代码 ErrorException为foreach()提供的参数无效(视图: F:\server\htdocs\yii\yumypizza\resources\views\shop\shopping cart.blade.php) 这是我的shop.shopping-cart代码Php 我需要惠特·拉瓦弗的帮助,php,laravel-5,Php,Laravel 5,你好,为什么我会出现这个错误 我需要小小的帮助 有错误代码 ErrorException为foreach()提供的参数无效(视图: F:\server\htdocs\yii\yumypizza\resources\views\shop\shopping cart.blade.php) 这是我的shop.shopping-cart代码 @extends('layouts.master') @section('title') THE YUMMI PIZZA @endsection @sectio
@extends('layouts.master')
@section('title')
THE YUMMI PIZZA
@endsection
@section('content')
@if(Session::has('cart'))
<div class="row">
<div class="col-sm-6 col-md-6 col-md-offset-3 col-sm-offset-3">
<ul class="list-group">
@foreach($products as $product)
<li class="list-group-item">
<span class="badge">{{ $product['qty'] }}</span>
<strong>{{ $product['item']['title'] }}</strong>
<span class="label label-success">{{ $product['price'] }}</span>
<div class="btn-group">
<button type="button" class="btn btn-primary btn-xs dropdown-toogle" data-toggle="dropdown">Action <span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="">Reduce by 1</a></li>
<li><a href="">Reduce All</a></li>
</ul>
</div>
</li>
@endforeach
</ul>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-md-6 col-md-offset-3 col-sm-offset-3">
<strong> Total: {{ $totalPrice }}</strong>
</div>
</div>
<hr>
<div class="row">
<div class="col-sm-6 col-md-6 col-md-offset-3 col-sm-offset-3">
<button type="button" class="btn btn-success">CheckOut</button>
</div>
</div>
@else
<div class="row">
<div class="col-sm-6 col-md-6 col-md-offset-3 col-sm-offset-3">
<h2>No Items in Cart!</h2>
</div>
</div>
@endif
@endsection
和路线
Route::get('/add-to-cart/{id}', [
'uses' => 'ProductController@getAddToCart',
'as' => 'product.addToCart'
]);
Route::get('/shopping-cart', [
'uses' => 'ProductController@getCart',
'as' => 'product.shoppingCart'
]);
如果你能帮我的话 在压缩函数中发送变量
$contents = $this->someFunction();
return view('admin.category.List', compact('contents'));
尝试
$products
并检查它包含的内容已定义的索引页,工作正常!她是一个公共函数getIndex(){$product=product::all();返回视图('shop.index',['products'=>$product]);},但我去购物车时遇到了问题
$contents = $this->someFunction();
return view('admin.category.List', compact('contents'));