【发布时间】:2019-05-21 20:29:29
【问题描述】:
有链接到我以前的问题,代码在哪里,也许它可以帮助你 Parse error: syntax error, unexpected '__construct' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
这是我遇到的问题
未定义索引:item(查看:C:\xampp\htdocs\laravel\resources\views\shoppingCart.blade.php)
这个错误在那里<strong><?php echo e($product['item']['name']); ?></strong>
这是我的路线
Route::get('shoppingCart', 'WebController@shoppingCart')->name('get.shoppingCart');
这是在我的网络控制器中
public function shoppingCart(){
if(!Session::has('cart')){
return view('shoppingCart');
}
$oldCart = Session::get('cart');
$cart = new Cart($oldCart);
return view('shoppingCart',['products'=>$cart->items]);
}
这是购物车的链接
<li><a href="{{ route('get.shoppingCart') }}">CART <span class="badge">{{Session::has('cart') ? '!' : ''}}</span></a></li>
这是我的购物车代码
@extends('layouts.main')
@section('content')
@if(Session::has('cart'))
<div>
<div>
<ul class="list-group">
@foreach($products as $product)
<li class="list-group-item"></li>
<strong>{{$product['item']['name']}}</strong>
<li><a href="#">Odstrániť</a></li>
@endforeach
</ul>
</div>
</div>
@else
<div>
<h2>V košíku nemáš žiadne položky!!!</h2>
</div>
@endif
@endsection
【问题讨论】:
-
您好,您应该提供回答您所需的所有详细信息,因为这是另一个问题。至少是发生错误的代码行,以及完整的错误(哪个索引未定义?)
-
@Angelika Beňová:无法理解你的问题
-
@AngelikaBeňová 如果遇到新错误,请根据新错误提问。您可以编辑您的问题,并根据错误输入正确的所有详细信息,然后我们可以轻松为您提供帮助
-
谢谢我编辑这个问题
标签: laravel indexing undefined