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
protected array $pendingEvents from EventGeneratorTrait
protected $table {@inheritdoc}
protected $dates {@inheritdoc}
static protected array $models A map of post types, as specified in the <code>type</code> column, to their classes.
string|null $type
int $id
int $discussion_id
int $number
Carbon $time
int|null $user_id
string|null $content
Carbon|null $edit_time
int|null $edit_user_id
Carbon|null $hide_time
int|null $hide_user_id
Discussion|null $discussion
User|null $user
User|null $editUser
User|null $hideUser
string $ip_address

Methods

static 
boot()

{@inheritdoc}

array
getDates()

Get the attributes that should be converted to dates.

mixed
getAttribute(string $key)

Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.

mixed
getCustomRelation(string $name)

Get a custom relation object.

void
afterSave(callable $callback)

Register a callback to be run once after the model is saved.

void
afterDelete(callable $callback)

Register a callback to be run once after the model is deleted.

callable[]
releaseAfterSaveCallbacks()

No description

callable[]
releaseAfterDeleteCallbacks()

No description

__call($method, $arguments)

{@inheritdoc}

raise(mixed $event)

Raise a new event.

array
releaseEvents()

Return and reset all pending events.

scopeWhereVisibleTo(Builder $query, User $actor)

Scope a query to only include records that are visible to a user.

bool
isVisibleTo(User $user)

Determine whether or not this post is visible to the given user.

BelongsTo
discussion()

Define the relationship with the post's discussion.

BelongsTo
user()

Define the relationship with the post's author.

BelongsTo
editUser()

Define the relationship with the user who edited the post.

BelongsTo
hideUser()

Define the relationship with the user who hid the post.

Builder
scopeAllTypes(Builder $query)

Get all posts, regardless of their type, by removing the <code>RegisteredTypesScope</code> global scope constraints applied on this model.

Post|object
newFromBuilder(array $attributes = [], string|null $connection = null)

Create a new model instance according to the post's type.

static array
getModels()

Get the type-to-model map.

static void
setModel(string $type, string $model)

Set the model for the given post type.

Details

static boot()

{@inheritdoc}

array getDates()

Get the attributes that should be converted to dates.

Return Value

array

mixed getAttribute(string $key)

Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.

Parameters

string $key

Return Value

mixed

protected mixed getCustomRelation(string $name)

Get a custom relation object.

Parameters

string $name

Return Value

mixed

void afterSave(callable $callback)

Register a callback to be run once after the model is saved.

Parameters

callable $callback

Return Value

void

void afterDelete(callable $callback)

Register a callback to be run once after the model is deleted.

Parameters

callable $callback

Return Value

void

callable[] releaseAfterSaveCallbacks()

Return Value

callable[]

callable[] releaseAfterDeleteCallbacks()

Return Value

callable[]

__call($method, $arguments)

{@inheritdoc}

Parameters

$method
$arguments

raise(mixed $event)

Raise a new event.

Parameters

mixed $event

array releaseEvents()

Return and reset all pending events.

Return Value

array

scopeWhereVisibleTo(Builder $query, User $actor)

Scope a query to only include records that are visible to a user.

Parameters

Builder $query
User $actor

bool isVisibleTo(User $user)

Determine whether or not this post is visible to the given user.

Parameters

User $user

Return Value

bool

BelongsTo discussion()

Define the relationship with the post's discussion.

Return Value

BelongsTo

BelongsTo user()

Define the relationship with the post's author.

Return Value

BelongsTo

BelongsTo editUser()

Define the relationship with the user who edited the post.

Return Value

BelongsTo

BelongsTo hideUser()

Define the relationship with the user who hid the post.

Return Value

BelongsTo

Builder scopeAllTypes(Builder $query)

Get all posts, regardless of their type, by removing the <code>RegisteredTypesScope</code> global scope constraints applied on this model.

Parameters

Builder $query

Return Value

Builder

Post|object newFromBuilder(array $attributes = [], string|null $connection = null)

Create a new model instance according to the post's type.

Parameters

array $attributes
string|null $connection

Return Value

Post|object

static array getModels()

Get the type-to-model map.

Return Value

array

static void setModel(string $type, string $model)

Set the model for the given post type.

Parameters

string $type The post type.
string $model The class name of the model for that type.

Return Value

void