Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events that span multiple days #19

Open
stevyrey opened this issue Jun 11, 2021 · 0 comments
Open

Events that span multiple days #19

stevyrey opened this issue Jun 11, 2021 · 0 comments

Comments

@stevyrey
Copy link

stevyrey commented Jun 11, 2021

This isn't currently handled and would be extremely useful.
Perhaps check to see if current day is in start and end ranges and populate each day with the event item.

below is my attempt it uses a multiday bool on the event - if it's missing it will default to old behaviour

#20

public function getEventsForDay($day, Collection $events) : Collection
{
    return $events->filter(function ($event) use ($day)
    {
        if(isset($event['multiday']) && $event['multiday']===true)
        {
            return $day->between(Carbon::parse($event['date']), Carbon::parse($event['end']));
        }
        return Carbon::parse($event['date'])->isSameDay($day);
    });
}

In event.blade.php

  @if(!isset($event['multiday']) || $event['multiday']!== true)
            {{$event['date']->format('G:i')}} - {{$event['end']->format('G:i')}}
        @endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant