class UserState extends AbstractModel

Models a discussion-user state record in the database.

Stores information about how much of a discussion a user has read. Can also be used to store other information, if the appropriate columns are added to the database, like a user's subscription status for 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 array $customCasts from AbstractModel
static array $defaults from AbstractModel
protected string|null $tableAlias An alias for the table name, used in queries. from AbstractModel
string[]|null $uniqueKeys If a model has unique keys, they should be defined here. from AbstractModel
protected array $pendingEvents from EventGeneratorTrait
protected $table
protected $casts
$incrementing
protected $fillable The attributes that are mass assignable.
int $user_id
int $discussion_id
Carbon|null $last_read_at
int|null $last_read_post_number
Discussion $discussion
User $user

Methods

static 
boot()

No description

__construct(array $attributes = [])

No description

array
getCasts()

No description

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.

array
releaseAfterSaveCallbacks()

No description

array
releaseAfterDeleteCallbacks()

No description

newModelQuery()

No description

qualifyColumn($column)

No description

mixed
withTableAlias(callable $callback)

No description

newCollection(array $models = [])

No description

__sleep()

No description

void
raise(object $event)

No description

array
releaseEvents()

Return and reset all pending events.

read(int $number)

Mark the discussion as being read up to a certain point. Raises the DiscussionWasRead event.

BelongsTo
discussion()

No description

BelongsTo
user()

No description

Builder
setKeysForSaveQuery(Builder $query)

Set the keys for a save update query.

Details

static boot()

__construct(array $attributes = [])

Parameters

array $attributes

array getCasts()

Return Value

array

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

array releaseAfterSaveCallbacks()

Return Value

array

array releaseAfterDeleteCallbacks()

Return Value

array

newModelQuery()

qualifyColumn($column)

Parameters

$column

mixed withTableAlias(callable $callback)

Parameters

callable $callback

Return Value

mixed

Collection newCollection(array $models = [])

Parameters

array $models

Return Value

Collection

__sleep()

void raise(object $event)

Parameters

object $event

Return Value

void

array releaseEvents()

Return and reset all pending events.

Return Value

array

UserState read(int $number)

Mark the discussion as being read up to a certain point. Raises the DiscussionWasRead event.

Parameters

int $number

Return Value

UserState

BelongsTo discussion()

Return Value

BelongsTo

BelongsTo user()

Return Value

BelongsTo

protected Builder setKeysForSaveQuery(Builder $query)

Set the keys for a save update query.

Parameters

Builder $query

Return Value

Builder