此应用程序使您可以创建产品报价。但是,当他们尝试从购物车中删除商品时,会出现以下错误:
[2015-06-29 20:58:28] production.ERROR:/app/controllers/CustomQuoteController.php:613中出现消息“试图获取非对象的属性”的异常“ ErrorException”
#0 /app/controllers/CustomQuoteController.php(613):Illuminate \ Exception \ Handler-> handleError(8,'试图获取p ...','/ var / www / ...',613,数组)
我删除了部分路径名。
613行是读到的 if($item_in_cart->name == $custom_quote_item->name)
public function removeFromQuote()
{
$item_exists = true;
$custom_quote_item = CustomQuoteItem::find(Input::get('id'));
$custom_quote_items = Session::get('custom_quote_items');
if(count($custom_quote_items) > 0 )
{
foreach($custom_quote_items as $key => $item_in_cart)
{
// line 613 below
if($item_in_cart->name == $custom_quote_item->name)
{
unset($custom_quote_items[$key]);
Session::set('custom_quote_items', $custom_quote_items);
return Redirect::back()->with('success', 'Item has been removed.');
}
}
}
return Redirect::back()->with('errors', 'Item was not removed.');
}
由于您都在613$item_in_cart
和$custom_quote_item
第613行上检索属性,因此这就是问题所在。其中之一不是对象,或者不包含property name
,如异常所指出的那样。
我将通过使用验证这两个变量都是对象dd($item_in_cart)
,并使用输出更新我们,我的猜测是$item_in_cart
问题所在,因为您是从会话中检索它并循环遍历它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句