filter ?: []; $data = [ ENTITY_INVOICE => Invoice::scope()->invoices(), ENTITY_QUOTE => Invoice::scope()->quotes(), ENTITY_TASK => Task::scope(), ENTITY_PAYMENT => Payment::scope(), ENTITY_EXPENSE => Expense::scope(), ]; foreach ($data as $type => $source) { if (! count($filter) || in_array($type, $filter)) { foreach ($source->get() as $entity) { $subColors = count($filter) == 1; $events[] = $entity->present()->calendarEvent($subColors); } } } return $events; } }