If I have a Laravel 5.5 model called User
that hasMany
Post
s and each Post
hasMany
Hit
s, is there an aggregate function I can call to get the total number of Hit
s for a User
across all Post
s, where the Hit
was created in the last week?
It seems like there may be a clever way to do it besides doing something like
$hits = $user->posts()->hits()
and then looping over those hits to check created date.
In this case it seems like raw sql would be better, but I figured there may be an Eloquent way to handle a situation like this.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2BwM3Aw
via IFTTT
Aucun commentaire:
Enregistrer un commentaire