laravel从空值

时间:2017-04-14 14:42:18

标签: php laravel laravel-5 laravel-5.3

我有这个功能

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

1 个答案:

答案 0 :(得分:4)

这是因为你有一个名为错误的实体。仔细看看你有的第74行

$notity->link = $link;

您已撰写notity,而您的变量名称为notify

相关问题