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 <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 $customCasts from AbstractModel
static $defaults from AbstractModel
protected string|null $tableAlias <p>An alias for the table name, used in queries.</p> from AbstractModel
int|null $id from AbstractModel
protected array $pendingEvents from EventGeneratorTrait
protected $table <p>{@inheritdoc}</p>
protected array $dates <p>The attributes that should be mutated to dates.</p>
protected string[] $fillable <p>The attributes that are mass assignable.</p>
int $user_id
int $discussion_id
Carbon|null $last_read_at
int|null $last_read_post_number
Discussion $discussion
User $user

Methods

static 
boot()

<p>{@inheritdoc}</p>

__construct(array $attributes = [])

<p>{@inheritdoc}</p>

getCasts()

<p>{@inheritdoc}</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>

newModelQuery()

No description

qualifyColumn($column)

No description

withTableAlias(callable $callback)

No description

newCollection(Collection|array $models = [])

No description

raise(mixed $event)

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

array
releaseEvents()

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

$this
read(int $number)

<p>Mark the discussion as being read up to a certain point. Raises the DiscussionWasRead event.</p>

BelongsTo
discussion()

<p>Define the relationship with the discussion that this state is for.</p>

BelongsTo
user()

<p>Define the relationship with the user that this state is for.</p>

Builder
setKeysForSaveQuery(Builder $query)

<p>Set the keys for a save update query.</p>

Details

static boot()

<p>{@inheritdoc}</p>

__construct(array $attributes = [])

<p>{@inheritdoc}</p>

Parameters

array $attributes

getCasts()

<p>{@inheritdoc}</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>

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

newModelQuery()

qualifyColumn($column)

Parameters

$column

withTableAlias(callable $callback)

Parameters

callable $callback

newCollection(Collection|array $models = [])

Parameters

Collection|array $models

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

$this read(int $number)

<p>Mark the discussion as being read up to a certain point. Raises the DiscussionWasRead event.</p>

Parameters

int $number

Return Value

$this

BelongsTo discussion()

<p>Define the relationship with the discussion that this state is for.</p>

Return Value

BelongsTo

BelongsTo user()

<p>Define the relationship with the user that this state is for.</p>

Return Value

BelongsTo

protected Builder setKeysForSaveQuery(Builder $query)

<p>Set the keys for a save update query.</p>

Parameters

Builder $query

Return Value

Builder