Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

access to relationship model from presenter #17

Open
mdeprezzo opened this issue Aug 11, 2014 · 3 comments
Open

access to relationship model from presenter #17

mdeprezzo opened this issue Aug 11, 2014 · 3 comments

Comments

@mdeprezzo
Copy link

Hi guys i don't know why but if inside the presenter class i try to access like a method on relationship model

$this->relations()->count()

i get an error message on method 'Call to undefined method'. Why ?

@jstoone
Copy link

jstoone commented Aug 11, 2014

@Mdpproduction have you tried accessing it through the entity?
$this->entity->posts()->count()

Make sure when you're querying the relationship with the sole purpose of counting it, to have access "posts" as a method, as above since that will only generate one "SELECT COUNT(*)" query, whereas
$this->entity->posts->count
would fetch all posts related to that entity and count them.

@mdeprezzo
Copy link
Author

Oh my fault! I'm so embarrassed! It's ok, thanks for reminding me

@jstoone
Copy link

jstoone commented Aug 11, 2014

You're very welcome, and no need to be embarrassed. :)

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

No branches or pull requests

2 participants