在laravel中按年度对发布数据进行分组

i'm trying to create timeline with laravel. I just want to grouping posts upon year like this:

2015
------
post1, created in 2015
post2, created in 2015
.
.
------
2014
post1, created in 2014
post1, created in 2014
.
.

I just want to print posts in view with this format.

I did not figure query for this build with laravel and eloquent.

You don't need anything special to achieve that. Just get all posts in descending order and display them adding some conditions.

For example:

$posts = Post::orderBy('created_at', 'DESC')->get();

$year = null;

foreach ($posts as $post) {
  if ($post->created_at->format('Y') != $year) {
    $year = $post->created_at->format('Y');
    echo $year."<br />";
  }
  echo $post->content.', created in  '.$year."<br />";
}