class Post extends AbstractModel
Traits
Properties
| bool | $timestamps | Indicates if the model should be timestamped. Turn off by default. | from AbstractModel |
|
| protected callable[] | $afterSaveCallbacks | An array of callbacks to be run once after the model is saved. | from AbstractModel |
|
| protected callable[] | $afterDeleteCallbacks | An array of callbacks to be run once after the model is deleted. | from AbstractModel |
|
| static array | $customCasts | from AbstractModel |
|
|
| static array | $defaults | from AbstractModel |
|
|
| static protected array<class-string,array<string,string>> | $castsCache | Resolved casts, keyed by model class. | from AbstractModel |
|
| protected string|null | $tableAlias | An alias for the table name, used in queries. | from AbstractModel |
|
| string[]|null | $uniqueKeys | If a model has unique keys, they should be defined here. | from AbstractModel |
|
| protected array | $pendingEvents | from EventGeneratorTrait |
|
|
| static protected array | $visibilityScopers | from ScopeVisibilityTrait |
|
|
| protected | $table |
|
||
| protected | $casts |
|
||
| static protected Post>> | $models | A map of post types, as specified in the `type` column, to their classes. |
|
|
| string|null | $type |
|
||
| int | $id |
|
||
| int | $discussion_id |
|
||
| int|Expression | $number |
|
||
| Carbon | $created_at |
|
||
| int|null | $user_id |
|
||
| string|null | $content |
|
||
| Carbon|null | $edited_at |
|
||
| int|null | $edited_user_id |
|
||
| $hidden_at |
|
|||
| $hidden_user_id |
|
|||
| string | $ip_address |
|
||
| bool | $is_private |
|
||
| Discussion|null | $discussion |
|
||
| User|null | $user |
|
||
| User|null | $editedUser |
|
||
| $hiddenUser |
|
Methods
Discard the resolved casts, so that newly registered ones are picked up.
Register a callback to be run once after the model is saved.
Register a callback to be run once after the model is deleted.
No description
Scope a query to only include records that are visible to a user.
Scope a query over one discussion's posts to those visible to the user, where the caller has already established that the DISCUSSION is visible.
Get all posts, regardless of their type, by removing the `RegisteredTypesScope` global scope constraints applied on this model.
Create a new model instance according to the post's type.
Details
at
line 82
static
boot()
in AbstractModel
at
line 100
__construct(array $attributes = [])
in AbstractModel
at
line 115
array
getCasts()
in AbstractModel
at
line 135
static void
flushCastsCache()
Discard the resolved casts, so that newly registered ones are picked up.
in AbstractModel
at
line 143
void
afterSave(callable $callback)
Register a callback to be run once after the model is saved.
in AbstractModel
at
line 151
void
afterDelete(callable $callback)
Register a callback to be run once after the model is deleted.
in AbstractModel
at
line 159
array
releaseAfterSaveCallbacks()
in AbstractModel
at
line 171
array
releaseAfterDeleteCallbacks()
in AbstractModel
at
line 183
newModelQuery()
in AbstractModel
at
line 195
qualifyColumn($column)
in AbstractModel
at
line 204
mixed
withTableAlias(callable $callback)
in AbstractModel
at
line 217
Collection
newCollection(array $models = [])
in AbstractModel
at
line 223
__sleep()
in EventGeneratorTrait
at
line 16
void
raise(object $event)
in EventGeneratorTrait
at
line 24
array
releaseEvents()
Return and reset all pending events.
in ScopeVisibilityTrait
at
line 28
static void
registerVisibilityScoper(callable $scoper, string|null $ability = null)
in ScopeVisibilityTrait
at
line 44
Builder
scopeWhereVisibleTo(Builder $query, User $actor, string $ability = 'view')
Scope a query to only include records that are visible to a user.
in ScopeVisibilityTrait
at
line 19
static Builder
whereVisibleTo(User $user)
at
line 135
Builder
scopeWhereVisibleToInDiscussion(Builder $query, User $actor, Discussion $discussion)
Scope a query over one discussion's posts to those visible to the user, where the caller has already established that the DISCUSSION is visible.
Applies the same registered `view` scopers as whereVisibleTo(), but lets scopers implementing {\Flarum\Post\Access\ScopesPostVisibilityWithinDiscussion} take their fast path: discussion-level access checks are evaluated once in PHP instead of as per-row subqueries, whose cost grows with the size of the discussion. Only meaningful when the query is restricted to the given discussion's posts.
at
line 157
BelongsTo
discussion()
at
line 162
BelongsTo
user()
at
line 167
BelongsTo
editedUser()
at
line 172
BelongsTo
hiddenUser()
at
line 181
Builder
scopeAllTypes(Builder $query)
Get all posts, regardless of their type, by removing the `RegisteredTypesScope` global scope constraints applied on this model.
at
line 193
Post|object
newFromBuilder(array $attributes = [], string|null $connection = null)
Create a new model instance according to the post's type.