G
G
GaserV2017-06-27 00:12:39
Laravel
GaserV, 2017-06-27 00:12:39

How to return records grouped by dates?

A question. There is a Post model. It has a link to Comment. It is necessary to return in json Post and comments by dates of the form: today, yesterday, 10/20/2010, etc. Not necessarily of course Today and Yesterday, but I would like to)
I try this, but the model with the connection simply returns:

$post = Post::where('id', $id)->with('comments')->groupBy('created_at')->get();

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question