2017-04-14 14 views
-1

創建默認對象我有這個laravel從空值

function notifyStore($storeId, $notification,$type, $link) 
{ 
    $notify = new App\Store_notification; 
    $notify->store_id = $storeId; 
    $notify->notification = $notification; 
    $notity->link = $link; 
    $notify->type = $type; 
    $notify->save(); 
} 

一個功能和控制器

$order = new Store_order; 
    $orderArray['user_id'] = $signed['user_id']; 
    $orderArray['store_id'] = $store->store_id; 
    $orderArray['payment_method'] = $signed['payment_id']; 
    $orderArray['address_info'] = $signed['address']; 
    $orderArray['invoice_id'] = $signed['invoice_id']; 
    $orderArray['order_status'] = 2; 
    $orderArray['created_at'] = Carbon::now()->format('Y-m-d H:i:s'); 
    $invoice = $order->insertGetId($orderArray); 
    notifyStore($store->store_id,"You have a order to review",3,$signed['invoice_id']); 

但每次我提交訂單時會生成此錯誤。我不知道它有什麼問題。它表示74行錯誤,74行是$notity->link = $link;。任何人都可以檢查並告訴我什麼是錯的?

錯誤

at HandleExceptions->handleError(2, 'Creating default object from empty value', 'C:\\wamp64\\www\\ABCProject\\app\\Http\\Helper.php', 74, array('storeId' => 1, 'notification' => 'You have a order to review', 'type' => 3, 'link' => '2017-1-6-888-8280', 'notify' => object(Store_notification), 'notity' => object(stdClass))) in Helper.php line 74 

回答

3

那是因爲你有一個名爲錯誤的實體。在該行74仔細看你有

$notity->link = $link; 

你已經寫notity而你的變量名是notify

+0

好感謝我知道了! – Alen