Skip to content

BaseSpace Model ​

Provides the shared ORM behavior for spaces, courses, space groups, and sidebar links.

Table ​

  • Table: fcom_spaces

  • Primary key: id

  • Extends: Model

Attributes ​

ColumnTypeNullableDefaultDescription
idBIGINT UNSIGNEDNo—Primary key for the row.
created_byBIGINT UNSIGNEDYes—WordPress user ID that created the record.
parent_idBIGINT UNSIGNEDYes—Parent row ID used for threading or hierarchy.
titleVARCHAR(194)No—Human-readable title stored for the record.
slugVARCHAR(194)No—Sanitized slug or public identifier.
logoTEXTYes—Logo stored for this record.
cover_photoTEXTYes—Cover Photo stored for this record.
descriptionLONGTEXTYes—Description stored for this record.
typeVARCHAR(100)Yes—Subtype discriminator for the row.
privacyVARCHAR(100)Yes'public'Visibility state used by feeds and spaces.
statusVARCHAR(100)Yes'published'Lifecycle or moderation status.
serialINT(11)Yes1Ordering index inside a group of related records.
settingsLONGTEXTYes—Serialized settings payload.
created_atTIMESTAMPYes—Creation timestamp maintained by the ORM.
updated_atTIMESTAMPYes—Update timestamp maintained by the ORM.

Relationships ​

MethodTypeTargetNotes
owner()belongsToUserSignature: —
space_pivot()belongsToSpaceUserPivotSignature: —
admins()belongsToManyUserSignature: —
posts()hasManyFeedSignature: —
comments()hasManyThroughCommentSignature: —
members()belongsToManyUserSignature: —
x_members()belongsToManyXProfileSignature: —
group()belongsToSpaceGroupSignature: —

Scopes ​

ScopeParametersPurpose
SearchBy$query, $searchSearch By scope declared on the model.
OnlyMain$queryOnly Main scope declared on the model.
FilterByUserId$query, $userIdFilter By User Id scope declared on the model.
ByUserAccess$query, $userIdBy User Access scope declared on the model.

Key Methods ​

MethodDescription
updateCustomData()Sanitizes and persists mutable space fields such as title, description, media, and settings.
getMembership()Returns the current user membership record for the space, including the pivot metadata.
isAdmin()Checks whether a user is an admin or, optionally, a moderator for the current space.
formatSpaceData()Normalizes related data before a space object is returned from controllers.
preloadMemberships()preload Memberships implemented on the model.
isCourseSpace()is Course Space implemented on the model.
isContentSpace()is Content Space implemented on the model.
defaultSettings()default Settings implemented on the model.
canViewMembers()can View Members implemented on the model.
verifyUserPermisson()verify User Permisson implemented on the model.
hasPaywallIntegration()has Paywall Integration implemented on the model.
updateCustomMeta()update Custom Meta implemented on the model.
syncTopics()sync Topics implemented on the model.

Usage Examples ​

php
use FluentCommunity\App\Models\BaseSpace;

$records = BaseSpace::query()
    ->searchBy('example')
    ->limit(10)
    ->get();

$first = BaseSpace::query()->first();

FluentCommunity developer documentation