Created
May 12, 2016 07:43
-
-
Save DDiimmkkaass/2ed2afc96b4ab96028ec6e3e49d3eade to your computer and use it in GitHub Desktop.
Laravel: Групована по роках і місяцях колекція для виводу новин
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$news = News::published()->active()->get()->groupBy(function ($date) { | |
return Carbon::parse($date->published_at)->formatLocalized('%Y'); | |
}); | |
$grouped = $news->map(function ($date) { | |
return ($date->groupBy(function ($item) { | |
return Carbon::parse($item->published_at)->formatLocalized('%B'); | |
})); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment