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 $customRelations from AbstractModel
static $dateAttributes from AbstractModel
static $defaults from AbstractModel
protected array $pendingEvents from EventGeneratorTrait
protected $table {@inheritdoc}
protected array $dates The attributes that should be mutated to dates.
int $user_id
int $discussion_id
Carbon|null $last_read_at
int|null $last_read_post_number
Discussion $discussion
User $user

Methods

static 
boot()

{@inheritdoc}

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

$this
read(int $number)

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

BelongsTo
discussion()

Define the relationship with the discussion that this state is for.

BelongsTo
user()

Define the relationship with the user that this state is for.

Builder
setKeysForSaveQuery(Builder $query)

Set the keys for a save update query.

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

$this read(int $number)

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

Parameters

int $number

Return Value

$this

BelongsTo discussion()

Define the relationship with the discussion that this state is for.

Return Value

BelongsTo

BelongsTo user()

Define the relationship with the user that this state is for.

Return Value

BelongsTo

protected Builder setKeysForSaveQuery(Builder $query)

Set the keys for a save update query.

Parameters

Builder $query

Return Value

Builder