class Post extends AbstractModel
Traits
Properties
bool | $timestamps | <p>Indicates if the model should be timestamped. Turn off by default.</p> | from AbstractModel | |
protected callable[] | $afterSaveCallbacks | <p>An array of callbacks to be run once after the model is saved.</p> | from AbstractModel | |
protected callable[] | $afterDeleteCallbacks | <p>An array of callbacks to be run once after the model is deleted.</p> | from AbstractModel | |
static | $customRelations | from AbstractModel | ||
static | $dateAttributes | from AbstractModel | ||
static | $defaults | from AbstractModel | ||
protected array | $pendingEvents | from EventGeneratorTrait | ||
static protected | $visibilityScopers | from ScopeVisibilityTrait | ||
protected | $table | |||
protected array | $dates | <p>The attributes that should be mutated to dates.</p> | ||
protected array | $casts | <p>The attributes that should be cast to native types.</p> | ||
static protected array | $models | <p>A map of post types, as specified in the <code>type</code> column, to their classes.</p> | ||
string|null | $type | |||
int | $id | |||
int | $discussion_id | |||
int | $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
<p>Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.</p>
<p>Register a callback to be run once after the model is saved.</p>
<p>Register a callback to be run once after the model is deleted.</p>
<p>Scope a query to only include records that are visible to a user.</p>
<p>Get all posts, regardless of their type, by removing the <code>RegisteredTypesScope</code> global scope constraints applied on this model.</p>
<p>Create a new model instance according to the post's type.</p>
Details
at
line 87
static
boot()
<p>{@inheritdoc}</p>
in AbstractModel
at
line 85
__construct(array $attributes = [])
<p>{@inheritdoc}</p>
in AbstractModel
at
line 105
array
getDates()
<p>Get the attributes that should be converted to dates.</p>
in AbstractModel
at
line 123
mixed
getAttribute(string $key)
<p>Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.</p>
in AbstractModel
at
line 149
protected mixed
getCustomRelation(string $name)
<p>Get a custom relation object.</p>
in AbstractModel
at
line 165
void
afterSave(callable $callback)
<p>Register a callback to be run once after the model is saved.</p>
in AbstractModel
at
line 176
void
afterDelete(callable $callback)
<p>Register a callback to be run once after the model is deleted.</p>
in AbstractModel
at
line 184
callable[]
releaseAfterSaveCallbacks()
in AbstractModel
at
line 196
callable[]
releaseAfterDeleteCallbacks()
in AbstractModel
at
line 208
__call($method, $arguments)
<p>{@inheritdoc}</p>
in EventGeneratorTrait
at
line 24
raise(mixed $event)
<p>Raise a new event.</p>
in EventGeneratorTrait
at
line 34
array
releaseEvents()
<p>Return and reset all pending events.</p>
in ScopeVisibilityTrait
at
line 20
static
registerVisibilityScoper($scoper, $ability = null)
in ScopeVisibilityTrait
at
line 41
scopeWhereVisibleTo(Builder $query, User $actor, string $ability = 'view')
<p>Scope a query to only include records that are visible to a user.</p>
at
line 128
bool
isVisibleTo(User $user)
<p>Determine whether or not this post is visible to the given user.</p>
at
line 138
BelongsTo
discussion()
<p>Define the relationship with the post's discussion.</p>
at
line 148
BelongsTo
user()
<p>Define the relationship with the post's author.</p>
at
line 158
BelongsTo
editedUser()
<p>Define the relationship with the user who edited the post.</p>
at
line 168
BelongsTo
hiddenUser()
<p>Define the relationship with the user who hid the post.</p>
at
line 180
Builder
scopeAllTypes(Builder $query)
<p>Get all posts, regardless of their type, by removing the <code>RegisteredTypesScope</code> global scope constraints applied on this model.</p>
at
line 192
Post|object
newFromBuilder(array $attributes = [], string|null $connection = null)
<p>Create a new model instance according to the post's type.</p>
at
line 217
static array
getModels()
<p>Get the type-to-model map.</p>
at
line 231
static void
setModel(string $type, string $model)
<p>Set the model for the given post type.</p>