title: Generating archive list for a blog in Laravel
body: <p>I am trying to generate an archive list for blog articles. The archive list should display year and date in reverse chronological order as follows:</p>
  
  <pre><code>2013 (21)
      - May (2)
      - April (3)
      - March (5)
      - February (1)
      - January (10)
  2012 (10)
      - December (6)
      - November (4)
  </code></pre>
  
  <p>The number inside <code>()</code> are the number of posts in that time period. When the year or month of the year has been selected, only the blog posts from that selected time period should be displayed.</p>
  
  <p>So far I've only been able to find out the year and month of each blog post by doing:</p>
  
  <pre><code>$posts = Post::all();
  $archive = array();
  foreach ($posts as $post) {
      $year = date('Y', strtotime($post-&gt;created_at));
      $month = date('m', strtotime($post-&gt;created_at));
  }
  </code></pre>
  
  <p>How do I go about achieving the above objectives?</p>