laravel-calendar icon indicating copy to clipboard operation
laravel-calendar copied to clipboard

Make setEvents accept MessageBag objects [feature request]

Open carcinocron opened this issue 10 years ago • 2 comments

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);

carcinocron avatar Aug 13 '14 22:08 carcinocron

Hi, nice idea, will look into it

makzumi avatar Sep 04 '14 16:09 makzumi

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?

rginnow avatar Sep 26 '14 22:09 rginnow