Thursday, March 30, 2017

Trying to get property on non-object with Laravel 5.1 and Vue 2

I have a url loading with data passed on from Laravel. I place the data in the vue data using blade syntax like this:

data: {
    id: "{!! ($header->id) !!}",
    vendor: '{!! $header->vendor_name !!}',
    orderDate: '{!! $header->orderDate !!}',
    list: [],
}

So far so good. The data is set properly.

Then there is a method that triggers when a row in the table is clicked:

methods: {
   findInventoryItem: function(rowId) {
       var header = this.id;
       url = '{!! url('part-order/find-inventory') !!}' + '?headerId=' + header + '&rowId=' + rowId;
       window.location.href = url;
   }

The url is setup properly.

The error happens when I click the table row. This error pops up.

Trying to get property of non-object (View: /code/zone/resources/views/parts/part-order.blade.php)

Notice that the error is not with the requested url but with the existing url.

The error is triggered by this line:

id: "{!! ($header->id) !!}",

Any ideas as to what is going on here?



via Robbie

Advertisement