Trying to get property 'links' of non-object