Skip to content

Calendar Model ​

A calendar holds events. Each event belongs to exactly one.

A calendar has no public page of its own, so its statuses are only public, private and draft: events in a private or draft calendar never appear on the public pages. With the FluentCommunity integration on, each discussion space gets its own calendar (meta.fcom_space_id) and posts outside any space go to a shared Community calendar (meta.fcom_global = true).

Class ​

  • Class: FluentEvent\App\Models\Calendar
  • Table: {prefix}fe_calendars
  • Primary key: id
  • Extends: Model
  • Model events: creating (registered in booted())
  • Source: fluent-event/app/Models/Calendar.php

Attributes ​

ColumnTypeCastFillableDescription
idbigint(20) unsigned—No
titlevarchar(255)—YesCalendar name. Stored sanitized; read back as plain text.
slugvarchar(191)—YesUnique slug. Generated from the title when empty.
descriptiontext—NoOptional. No screen or endpoint sets it yet.
statusvarchar(64)—Yespublic, private or draft.
metalongtextarrayYesOpen-ended JSON. See below.
created_bybigint(20) unsignedintNoThe WordPress user who created the calendar. Set automatically on create.
created_attimestamp—No
updated_attimestamp—No

Mass assignment

Only the columns marked Fillable can be set through create() or fill(). description, created_by are not fillable: created_by is set from the current user when the calendar is created.

Computed Attributes ​

AttributeAppended to JSONDescription
titleNoDecodes the stored title to plain text. Escape it wherever you print it.

The meta Column ​

Calendar::defaultMeta() documents the keys. New per-calendar settings land here without a migration.

KeyMeaning
theme_colorSix-digit hex colour, default #0099ff. Colours the calendar's events in the admin.
fcom_space_idSet by the FluentCommunity bridge: the space this calendar belongs to.
fcom_globalSet by the FluentCommunity bridge: true on the Community calendar.

Constants ​

ConstantValueMeaning
Calendar::STATUSES"public,private,draft"Every calendar status.
Calendar::DEFAULT_THEME_COLOR"#0099ff"The colour a new calendar gets.

Relationships ​

MethodTypeRelated ModelKeys
events()hasManyEventcalendar_id → id
guests()hasManyGuestcalendar_id → id

Scopes ​

ScopeParametersDescription
searchBy()$searchMatches title or slug with LIKE.
byStatus()$statusLimits to one status or a list of statuses.

Methods ​

MethodDescription
::titleMaxLength()The title length limit, after the fluent_event/calendar_title_max_length filter.
::defaultMeta()The meta keys and their defaults.

Usage ​

php
use FluentEvent\App\Models\Calendar;

$calendars = Calendar::query()
    ->byStatus('public')
    ->withCount(['events', 'guests'])
    ->orderBy('title')
    ->get();

FluentEvent developer documentation