makzumi / laravel-calendar

Flexible Calendar for Laravel 4
58 stars 31 forks source link

Make setEvents accept MessageBag objects [feature request] #14

Open carcinocron opened 10 years ago

carcinocron commented 10 years ago

Your example array:

        $events = array(
            "2014-08-09 10:30:00" => array(
                "Event 1",
                "Event 2 <strong> with html</stong>",
            ),
            "2014-08-12 14:12:23" => array(
                "Event 3",
            ),
            "2014-09-14 08:00:00" => array(
                "Event 4",
            ),
        );
        $cal->setEvents($events);

can be rewritten as:

$events = new Illuminate\Support\MessageBag;
$events->add("2014-08-09 10:30:00", "Event 1");
$events->add("2014-08-09 10:30:00", "Event 2 <strong> with html</stong>");
$events->add("2014-08-12 14:12:23", "Event 3");
$events->add("2014-09-14 08:00:00", "Event 4");
$cal->setEvents($events);

Currently, it works if you use $cal->setEvents($events->toArray()); instead.

MessageBag has cool features like $bag1->merge($bag2);

makzumi commented 10 years ago

Hi, nice idea, will look into it

rginnow commented 9 years ago

It looks like MessageBag comes with Laravel 4.2 now... this would make the code cleaner. Is it as effective? And how would this work with @makzumi's array_group_by() function?