The fetchEvents method in your widget must return an array of event objects. You have two options:
1. Standard Array (FullCalendar format)
Return an associative array following the FullCalendar event object specification. Common keys include title, start, end, and url.
2. Using the EventData class
For a more fluent API, use the Saade\FilamentFullCalendar\Data\EventData class. This is recommended for cleaner code.
Supported EventData methods include:
id($id)title($title)start($start)end($end)url($url, $shouldOpenUrlInNewTab = false)
<?php
namespace App\
Filament\
Widgets;
use Saade\
FilamentFullCalendar\
Widgets\
FullCalendarWidget;
use Saade\
FilamentFullCalendar\
Data\
EventData;
use App\
Models\
Event;
class CalendarWidget extends FullCalendarWidget
{
public function fetchEvents(array $fetchInfo): array
{
return Event::query()
->where('starts_at', '>=', $fetchInfo['start'])
->where('ends_at', '<=', $fetchInfo['end'])
->get()
->map(
fn (Event $event) => EventData::make()
->id($event->uuid)
->title($event->name)
->start($event->starts_at)
->end($event->ends_at)
->url(
url: EventResource::getUrl(name: 'view', parameters: ['record' => $event]),
shouldOpenUrlInNewTab: true
)
)
->toArray();
}
}