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 | $customRelations | from AbstractModel |
|
|
| static | $dateAttributes | from AbstractModel |
|
|
| static | $defaults | from AbstractModel |
|
|
| int | $id |
|
||
| protected array | $pendingEvents | from EventGeneratorTrait |
|
|
| static protected | $visibilityScopers | from ScopeVisibilityTrait |
|
|
| protected | $table |
|
||
| protected array | $dates | The attributes that should be mutated to dates. |
|
|
| protected array | $casts | The attributes that should be cast to native types. |
|
|
| static protected array | $models | A map of post types, as specified in the `type` column, to their classes. |
|
|
| string|null | $type |
|
||
| 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 |
|
|||
| Discussion|null | $discussion |
|
||
| User|null | $user |
|
||
| User|null | $editedUser |
|
||
| $hiddenUser |
|
|||
| string | $ip_address |
|
||
| bool | $is_private |
|
Methods
Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.
Register a callback to be run once after the model is saved.
Register a callback to be run once after the model is deleted.
Scope a query to only include records that are visible to a user.
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 86
static
boot()
{@inheritdoc}
in AbstractModel
at
line 87
__construct(array $attributes = [])
{@inheritdoc}
in AbstractModel
at
line 107
array
getDates()
Get the attributes that should be converted to dates.
in AbstractModel
at
line 125
mixed
getAttribute(string $key)
Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.
in AbstractModel
at
line 151
protected mixed
getCustomRelation(string $name)
Get a custom relation object.
in AbstractModel
at
line 167
void
afterSave(callable $callback)
Register a callback to be run once after the model is saved.
in AbstractModel
at
line 178
void
afterDelete(callable $callback)
Register a callback to be run once after the model is deleted.
in AbstractModel
at
line 186
callable[]
releaseAfterSaveCallbacks()
in AbstractModel
at
line 198
callable[]
releaseAfterDeleteCallbacks()
in AbstractModel
at
line 210
__call($method, $arguments)
{@inheritdoc}
in EventGeneratorTrait
at
line 24
raise(mixed $event)
Raise a new event.
in EventGeneratorTrait
at
line 34
array
releaseEvents()
Return and reset all pending events.
in ScopeVisibilityTrait
at
line 20
static
registerVisibilityScoper($scoper, $ability = null)
in ScopeVisibilityTrait
at
line 41
scopeWhereVisibleTo(Builder $query, User $actor, string $ability = 'view')
Scope a query to only include records that are visible to a user.
at
line 127
bool
isVisibleTo(User $user)
Determine whether or not this post is visible to the given user.
at
line 137
BelongsTo
discussion()
Define the relationship with the post's discussion.
at
line 147
BelongsTo
user()
Define the relationship with the post's author.
at
line 157
BelongsTo
editedUser()
Define the relationship with the user who edited the post.
at
line 167
BelongsTo
hiddenUser()
Define the relationship with the user who hid the post.
at
line 179
Builder
scopeAllTypes(Builder $query)
Get all posts, regardless of their type, by removing the `RegisteredTypesScope` global scope constraints applied on this model.
at
line 191
Post|object
newFromBuilder(array $attributes = [], string|null $connection = null)
Create a new model instance according to the post's type.
at
line 216
static array
getModels()
Get the type-to-model map.
at
line 230
static void
setModel(string $type, string $model)
Set the model for the given post type.