面對這樣的錯誤:總是得到錯誤的時候車是空的,Laravel 5
ErrorException in CartController.php line 35: Trying to get property of non-object
這是代碼:
public function index()
{
$this->data['details'] = Cart::content();
$this->data['shipping'] = Shipping::where('region_category_id',session('location'))->where('type',session('type_komoditi'))->first();
$regType = session('regType');
$regId = session('id_wilayah');
$qReg = RegionCategory::find($regId);
if($regType == 'children') {
$this->data['minimalWeight'] = $qReg->minimal_weight;
//$this->data['minimalBuy'] = $qReg->min_buy;
}
$this->data['minimalBuy'] = $qReg->min_buy; //this is line 35
$this->data['regType'] = $regType;
\Session::put('price',Cart::total());
\Session::put('totalPrice',Cart::total());
\Session::put('paycode',0);
return view('client.carts.index',$this->data);
}
當我刪除了錯誤消失線35,但該代碼對使用最小購買過濾器非常重要。 如何解決此錯誤?
什麼是$這個 - >數據?哪條線是35線? –