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
Carbon|null $hidden_at
int|null $hidden_user_id
Discussion|null $discussion
User|null $user
User|null $editedUser
User|null $hiddenUser
string $ip_address
bool $is_private

Methods

static 
boot()

<p>{@inheritdoc}</p>

__construct(array $attributes = [])

<p>{@inheritdoc}</p>

array
getDates()

<p>Get the attributes that should be converted to dates.</p>

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>

mixed
getCustomRelation(string $name)

<p>Get a custom relation object.</p>

void
afterSave(callable $callback)

<p>Register a callback to be run once after the model is saved.</p>

void
afterDelete(callable $callback)

<p>Register a callback to be run once after the model is deleted.</p>

callable[]
releaseAfterSaveCallbacks()

No description

callable[]
releaseAfterDeleteCallbacks()

No description

__call($method, $arguments)

<p>{@inheritdoc}</p>

raise(mixed $event)

<p>Raise a new event.</p>

array
releaseEvents()

<p>Return and reset all pending events.</p>

static 
registerVisibilityScoper($scoper, $ability = null)

No description

scopeWhereVisibleTo(Builder $query, User $actor, string $ability = 'view')

<p>Scope a query to only include records that are visible to a user.</p>

bool
isVisibleTo(User $user)

<p>Determine whether or not this post is visible to the given user.</p>

BelongsTo
discussion()

<p>Define the relationship with the post's discussion.</p>

BelongsTo
user()

<p>Define the relationship with the post's author.</p>

BelongsTo
editedUser()

<p>Define the relationship with the user who edited the post.</p>

BelongsTo
hiddenUser()

<p>Define the relationship with the user who hid the post.</p>

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>

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

<p>Create a new model instance according to the post's type.</p>

static array
getModels()

<p>Get the type-to-model map.</p>

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

<p>Set the model for the given post type.</p>

Details

static boot()

<p>{@inheritdoc}</p>

__construct(array $attributes = [])

<p>{@inheritdoc}</p>

Parameters

array $attributes

array getDates()

<p>Get the attributes that should be converted to dates.</p>

Return Value

array

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>

Parameters

string $key

Return Value

mixed

protected mixed getCustomRelation(string $name)

<p>Get a custom relation object.</p>

Parameters

string $name

Return Value

mixed

void afterSave(callable $callback)

<p>Register a callback to be run once after the model is saved.</p>

Parameters

callable $callback

Return Value

void

void afterDelete(callable $callback)

<p>Register a callback to be run once after the model is deleted.</p>

Parameters

callable $callback

Return Value

void

callable[] releaseAfterSaveCallbacks()

Return Value

callable[]

callable[] releaseAfterDeleteCallbacks()

Return Value

callable[]

__call($method, $arguments)

<p>{@inheritdoc}</p>

Parameters

$method
$arguments

raise(mixed $event)

<p>Raise a new event.</p>

Parameters

mixed $event

array releaseEvents()

<p>Return and reset all pending events.</p>

Return Value

array

static registerVisibilityScoper($scoper, $ability = null)

Parameters

$scoper
$ability

scopeWhereVisibleTo(Builder $query, User $actor, string $ability = 'view')

<p>Scope a query to only include records that are visible to a user.</p>

Parameters

Builder $query
User $actor
string $ability

bool isVisibleTo(User $user)

<p>Determine whether or not this post is visible to the given user.</p>

Parameters

User $user

Return Value

bool

BelongsTo discussion()

<p>Define the relationship with the post's discussion.</p>

Return Value

BelongsTo

BelongsTo user()

<p>Define the relationship with the post's author.</p>

Return Value

BelongsTo

BelongsTo editedUser()

<p>Define the relationship with the user who edited the post.</p>

Return Value

BelongsTo

BelongsTo hiddenUser()

<p>Define the relationship with the user who hid the post.</p>

Return Value

BelongsTo

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>

Parameters

Builder $query

Return Value

Builder

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

<p>Create a new model instance according to the post's type.</p>

Parameters

array $attributes
string|null $connection

Return Value

Post|object

static array getModels()

<p>Get the type-to-model map.</p>

Return Value

array

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

<p>Set the model for the given post type.</p>

Parameters

string $type <p>The post type.</p>
string $model <p>The class name of the model for that type.</p>

Return Value

void