Skip to content

Event Model ​

The typed half of an event: the fe_event_details row that sits beside its fe_event post.

The post relation holds the identity: title and description are computed attributes that read post_title and post_content. Eager load the post (->with('post')) whenever you read titles in a loop, or each event runs its own query.

Class ​

  • Class: FluentEvent\App\Models\Event
  • Table: {prefix}fe_event_details
  • Primary key: id
  • Extends: Model
  • Source: fluent-event/app/Models/Event.php

Attributes ​

ColumnTypeCastFillableDescription
idbigint(20) unsigned—No
post_idbigint(20) unsignedintYesThe fe_event post in wp_posts. Unique: one details row per post.
calendar_idbigint(20) unsignedintYesThe calendar that holds the event.
parent_event_idbigint(20) unsigned—YesReserved for recurrence. Always NULL today.
statusvarchar(64)—Yespublic, unlisted, private or draft. The post status follows it.
start_atdatetime—YesStart, in UTC.
end_atdatetime—YesEnd, in UTC. Always after start_at.
timezonevarchar(64)—YesThe organizer's time zone, for example Europe/Berlin. Local times are shown in it.
venue_typevarchar(64)—Yesoffline or online.
metalongtextarrayYesOpen-ended JSON. See below.
created_attimestamp—No
updated_attimestamp—No

Computed Attributes ​

AttributeAppended to JSONDescription
titleYesThe post title as plain text, with &, <, > and quotes decoded. Escape it wherever you print it.
descriptionNoThe post content, run through wp_kses_post(). Not appended by default: call ->append('description').
start_at_localYesstart_at in the event's own time zone. Use it on the event page and in guest emails.
end_at_localYesend_at in the event's own time zone.
start_at_siteYesstart_at in the site's time zone. Lists and the date filters use it.
end_at_siteYesend_at in the site's time zone.

Hidden from JSON: post.

The meta Column ​

Event::defaultMeta() documents the keys. Saves merge into the stored value, so a key you add yourself survives the plugin's own updates.

KeyMeaning
entry_typeHow people join: rsvp (going / not going), open (a Register button) or none (view only).
show_guest_countyes or no: show how many people are going.
capacityThe most guests that can be going at once, for rsvp and open events. 0 (the default) means no limit. Going and checked-in guests hold a seat. Admins can add guests past it.
show_spots_leftyes or no (the default): show the spots left on an event with a capacity. With show_guest_count also on, the event page shows a meter.
start_displayHow the event page shows the time before the start: relative ("Starts in 3 days", the default) or countdown (a live countdown).
cover_urlCover image URL. Images are stored as URLs, never as attachment IDs.
online_meeting_urlMeeting link for an online event. Shown only to guests who hold a seat.
venueVenue name for an offline event.
addressAddress for an offline event.
description_mdThe description as Markdown, as typed in the editor. The post holds the rendered HTML.

Constants ​

ConstantValueMeaning
Event::STATUSES"public,unlisted,private,draft"Every event status.
Event::LIVE_STATUSES["public","unlisted","private"]Statuses that count as a running event for reminders and the community portal.
Event::VENUE_TYPES"offline,online"Allowed venue_type values.
Event::ENTRY_TYPES"rsvp,open,none"Allowed meta.entry_type values.
Event::SEAT_STATUSES["going","checked_in"]Guest statuses that hold a seat. Only these get reminders and the meeting link.
Event::POST_STATUSES{"public":"publish","unlisted":"publish","private":"private","draft":"draft"}Event status → post_status of its post.

Relationships ​

MethodTypeRelated ModelKeys
guests()hasManyGuestevent_id → id
calendar()belongsToCalendarcalendar_id → id
post()belongsToPostpost_id → ID

Scopes ​

ScopeParametersDescription
searchBy()$searchMatches the post title with LIKE.
byCalendar()$calendarIdLimits to one calendar. A falsy ID adds no condition.
byStatus()$statusLimits to one status or a list of statuses.
inDateRange()$from, $toEvents that overlap a Y-m-d range, read as whole days in the site's time zone.
byPeriod()$periodupcoming (not ended, soonest first), past (ended, latest first), or anything else: upcoming first, then by distance from now.

Methods ​

MethodDescription
::defaultMeta()The meta keys and their defaults.
::venueMaxLength()The venue length limit, after the fluent_event/event_venue_max_length filter.
::postStatusFor($status)Maps an event status to a post_status.

Usage ​

php
use FluentEvent\App\Models\Event;

// The next five public events in calendar 3, with their posts loaded.
$events = Event::query()
    ->with('post')
    ->byCalendar(3)
    ->byStatus('public')
    ->byPeriod('upcoming')
    ->limit(5)
    ->get();

foreach ($events as $event) {
    echo esc_html($event->title) . ' — ' . esc_html($event->start_at_local);
}

FluentEvent developer documentation