N
N
naneri2014-10-14 10:22:16
ORM
naneri, 2014-10-14 10:22:16

How to distribute data by dates using Eloquent?

There was such a problem.
I have a post table.
In it, each post has a user_id and a date.
It is necessary to get the number of posts that were left by the user for all days after a certain date.
That is the function

function (user_id, date) {
   ...
}

How to get? In theory, I can get all the posts and then count in the array how many posts with a certain date - but I'm not sure if this is the right solution

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
cha-cha, 2014-10-14
@cha-cha

DB::table('posts')
    ->where('user_id', '=', *user_id_here*)
    ->where('date', '>', *date_here*)
    ->count();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question