public function fetchEvents(array $fetchInfo): array
{
$record = isset($this->record);
return Event::query()
->when($record, function ($query) {
$query->where('property_id', $this->record->id);
})
->get()
->map(function (Event $event) {
$title = $event->label->name . ' | ' . $event->property->name;
return [
'id' => $event->id,
'title' => $title,
'start' => $event->start->format('Y-m-d'),
'end' => $event->end->format('Y-m-d')
];
})
->toArray();
}
public function fetchEvents(array $fetchInfo): array
{
$record = isset($this->record);
return Event::query()
->when($record, function ($query) {
$query->where('property_id', $this->record->id);
})
->get()
->map(function (Event $event) {
$title = $event->label->name . ' | ' . $event->property->name;
return [
'id' => $event->id,
'title' => $title,
'start' => $event->start->format('Y-m-d'),
'end' => $event->end->format('Y-m-d')
];
})
->toArray();
}