laravel use collection each
<?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);
}
}