class CommentPost extends Post

A standard comment in a discussion.

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
protected array $pendingEvents from EventGeneratorTrait
protected $table from Post
protected array $dates The attributes that should be mutated to dates. from Post
protected array $casts The attributes that should be cast to native types. from Post
static protected array $models A map of post types, as specified in the <code>type</code> column, to their classes. from Post
static $type {@inheritdoc}
int $id from Post
int $discussion_id from Post
int $number from Post
Carbon $created_at from Post
int|null $user_id from Post
string|null $content from Post
Carbon|null $edited_at from Post
int|null $edited_user_id from Post
Carbon|null $hidden_at from Post
int|null $hidden_user_id from Post
Discussion|null $discussion from Post
User|null $user from Post
User|null $editedUser from Post
User|null $hiddenUser from Post
string $ip_address from Post
bool $is_private from Post
static protected Formatter $formatter The text formatter instance.
string $parsed_content

Methods

static 
boot()

{@inheritdoc}

from Post
__construct(array $attributes = [])

{@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.

from Post
BelongsTo
discussion()

Define the relationship with the post's discussion.

from Post
BelongsTo
user()

Define the relationship with the post's author.

from Post
BelongsTo
editedUser()

Define the relationship with the user who edited the post.

from Post
BelongsTo
hiddenUser()

Define the relationship with the user who hid the post.

from 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.

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

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

from Post
static array
getModels()

Get the type-to-model map.

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

Set the model for the given post type.

from Post
static CommentPost
reply(int $discussionId, string $content, int $userId, string $ipAddress)

Create a new instance in reply to a discussion.

$this
revise(string $content, User $actor)

Revise the post's content.

$this
hide(User $actor = null)

Hide the post.

$this
restore()

Restore the post.

string
getContentAttribute(string $value)

Unparse the parsed content.

string
getParsedContentAttribute()

Get the parsed/raw content.

setContentAttribute(string $value)

Parse the content before it is saved to the database.

setParsedContentAttribute(string $value)

Set the parsed/raw content.

string
formatContent(ServerRequestInterface $request = null)

Get the content rendered as HTML.

static Formatter
getFormatter()

Get the text formatter instance.

static 
setFormatter(Formatter $formatter)

Set the text formatter instance.

Details

static boot()

{@inheritdoc}

__construct(array $attributes = [])

{@inheritdoc}

Parameters

array $attributes

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 editedUser()

Define the relationship with the user who edited the post.

Return Value

BelongsTo

BelongsTo hiddenUser()

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

static CommentPost reply(int $discussionId, string $content, int $userId, string $ipAddress)

Create a new instance in reply to a discussion.

Parameters

int $discussionId
string $content
int $userId
string $ipAddress

Return Value

CommentPost

$this revise(string $content, User $actor)

Revise the post's content.

Parameters

string $content
User $actor

Return Value

$this

$this hide(User $actor = null)

Hide the post.

Parameters

User $actor

Return Value

$this

$this restore()

Restore the post.

Return Value

$this

string getContentAttribute(string $value)

Unparse the parsed content.

Parameters

string $value

Return Value

string

string getParsedContentAttribute()

Get the parsed/raw content.

Return Value

string

setContentAttribute(string $value)

Parse the content before it is saved to the database.

Parameters

string $value

setParsedContentAttribute(string $value)

Set the parsed/raw content.

Parameters

string $value

string formatContent(ServerRequestInterface $request = null)

Get the content rendered as HTML.

Parameters

ServerRequestInterface $request

Return Value

string

static Formatter getFormatter()

Get the text formatter instance.

Return Value

Formatter

static setFormatter(Formatter $formatter)

Set the text formatter instance.

Parameters

Formatter $formatter