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 UNSIGNEDNoPrimary key for the row.
created_byBIGINT UNSIGNEDYesWordPress user ID that created the record.
parent_idBIGINT UNSIGNEDYesParent row ID used for threading or hierarchy.
titleVARCHAR(194)NoHuman-readable title stored for the record.
slugVARCHAR(194)NoSanitized slug or public identifier.
logoTEXTYesLogo stored for this record.
cover_photoTEXTYesCover Photo stored for this record.
descriptionLONGTEXTYesDescription stored for this record.
typeVARCHAR(100)YesSubtype 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.
settingsLONGTEXTYesSerialized settings payload.
created_atTIMESTAMPYesCreation timestamp maintained by the ORM.
updated_atTIMESTAMPYesUpdate 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.
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