Skip to content

Conversation

mendicm
Copy link

@mendicm mendicm commented Sep 14, 2016

When accessing a relation via the magic __get method on Elasticquent loaded model, unnecessary queries to the datatabase are performed if the relation is empty,. For example:

$product = Product::search('product_slug')->first();
$properties = $product->properties;

If the properties related model (BelongsToMany relationship) is an empty array on ElasticSearch document the relation on the $product model isn't loaded and a query to the database is performed. With this fix we prevent this unnecessary queries.

…y on the elastic document. This prevents future queries when accessing the relationship via the magic __get method.
@mendicm
Copy link
Author

mendicm commented May 15, 2017

mmmm.... Hi?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant