* @author Connor S. Parks * @author Antoine Girard */ class StickiedComposer { /** * Bind data to the view. * * @param \Illuminate\Contracts\View\View $view * * @return void */ public function compose(View $view) { $stickiedIncidents = Incident::stickied()->orderBy('occurred_at', 'desc')->get()->groupBy(function (Incident $incident) { return app(DateFactory::class)->make($incident->is_scheduled ? $incident->scheduled_at : $incident->occurred_at)->toDateString(); }); $view->withStickiedIncidents($stickiedIncidents); } }