Created
October 16, 2014 11:49
-
-
Save lifesign/74f52cfdff1de48e60c8 to your computer and use it in GitHub Desktop.
laravel use collection each
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
<?php | |
class PagesController extends BaseController | |
{ | |
public function index() | |
{ | |
$featuredEvents = Event::where('featured', '1')->get(); | |
$featuredEvents->each(function ($event) { | |
$event->dateFormatted = Carbon::createFromFormat('d/m/Y', $event->date)->formatLocalized('%A %d %B'); | |
}); | |
return View::make('index')->with('featuredEvents', $featuredEvents); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment