mardi 31 janvier 2017

Using with and withCount together in laravel eloquent

withCount is a new method of laravel to return count of the relations. I'm trying to use with and withCount together. For example:

Article::with('Comments')->withCount('Comments')->paginate();

Problem I'm facing is, in the results is see for example:

comments_count = 10
comments = []

It returns comments array null. I don't know is it possible to get both the results or not. In some articles on different sites, i see withCount still has some restrictions. But not sure what I'm trying to do is possible or not.

Please help me to know about this issue.

Thank you,



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2kmD7sr
via IFTTT

Aucun commentaire:

Enregistrer un commentaire