saade / filament-fullcalendar

The Most Popular JavaScript Calendar as a Filament Widget
MIT License
269 stars 83 forks source link

The previous month's event does not carry over to the next month. #191

Closed nickjangveladze closed 2 months ago

nickjangveladze commented 3 months ago

I have 2 events:

  1. From July 27th to August 8th.
  2. From August 9th to August 17th.

For example, when I'm in July, the first event is visible from July 27th to August 9th, but when I move to August, the first event is not visible until August 9th. Only the second event is visible from August 9th to August 17th.

July

Screenshot 2024-06-10 at 22 00 57

August

Screenshot 2024-06-10 at 22 01 52
taher-k5 commented 2 months ago

@nickjangveladze I am facing the same issue. Were you able to resolve it? Can we use Recurring Events here?

saade commented 2 months ago

@nickjangveladze @taher-k5 isnt that just a query issue?

$fetchInfo['start'] would be 2024-08-01 when you're in August, excluding the events that started in July

saade commented 2 months ago

I hope my comment above fixed your issue, please reopen this if needed.

YonkoSam commented 2 months ago

so whats the fix ? i dont get it

taher-k5 commented 1 month ago

@YonkoSam You need to remove where condition from query in fetchEvents function

public function fetchEvents(array $fetchInfo): array
    {
        return Event::query()
            ->where('starts_at', '>=', $fetchInfo['start']) // remove this
            ->where('ends_at', '<=', $fetchInfo['end']) // remove this
            ->get()
            ->map(
                fn (Event $event) => [
                    'title' => $event->id,
                    'start' => $event->starts_at,
                    'end' => $event->ends_at,
                    'url' => EventResource::getUrl(name: 'view', parameters: ['record' => $event]),
                    'shouldOpenUrlInNewTab' => true
                ]
            )
            ->all();
    }
YonkoSam commented 1 month ago

wouldn't that make it very bad optimized to query all the task each time

mgkimsal commented 1 month ago

@YonkoSam You could subtract one month from the 'start' during your fetch, so you'd get anything that started in the previous month. Looking at August? Find events from July 1 - Aug 31, etc.

Or... further back if you have any events that might span 2 months, etc.