Trying to get property 'category' of non-object