'Boolean(1)', ]; private static $has_many = [ 'Notifications' => Notification::class, ]; public function updateCMSFields(FieldList $fields) { $tab = $fields->findOrMakeTab('Root.Notifications'); if(!$this->owner->exists()) { $tab->push(LiteralField::create( 'NotificationsNotice', '

The object must be saved before notifications can be added

' )); return null; } $items = $this->owner->Notifications(); $config = GridFieldConfig::create(); $config->addComponents([ new GridFieldToolbarHeader(), new GridFieldTitleHeader(), new GridFieldEditableColumns(), new GridFieldAddNewInlineButton('toolbar-header-right'), new GridFieldDetailForm(), new GridFieldEditButton(), new GridFieldDeleteAction(), ]); $tab->setChildren(FieldList::create( HeaderField::create('NotificationsHeader','Notifications'), LiteralField::create( 'CurrentNotifications', 'Current:' .$this->owner->renderWith('App\\Objects\\NotificationsList') ), CheckboxField::create('ShowNotifications'), GridField::create( 'Notifications', '', $items, $config ) )); } public function NotificationsToday() { $items = $this->owner->Notifications(); $time = time(); return $items->filter([ 'DateOn:LessThanOrEqual' => date('Y-m-d', $time), 'DateOff:GreaterThanOrEqual' => date('Y-m-d', $time), ]); } }