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 | $customCasts | from AbstractModel |
|
|
| static | $defaults | from AbstractModel |
|
|
| int|null | $id | from AbstractModel |
|
|
| protected array | $pendingEvents | from EventGeneratorTrait |
|
|
| protected | $table | {@inheritdoc} |
|
|
| protected array | $dates | The attributes that should be mutated to dates. |
|
|
| protected string[] | $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
Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.
Register a callback to be run once after the model is saved.
Register a callback to be run once after the model is deleted.
Mark the discussion as being read up to a certain point. Raises the DiscussionWasRead event.
Details
in AbstractModel
at
line 67
static
boot()
{@inheritdoc}
in AbstractModel
at
line 87
__construct(array $attributes = [])
{@inheritdoc}
in AbstractModel
at
line 105
getCasts()
{@inheritdoc}
in AbstractModel
at
line 123
mixed
getAttribute(string $key)
Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.
in AbstractModel
at
line 149
protected mixed
getCustomRelation(string $name)
Get a custom relation object.
in AbstractModel
at
line 165
void
afterSave(callable $callback)
Register a callback to be run once after the model is saved.
in AbstractModel
at
line 176
void
afterDelete(callable $callback)
Register a callback to be run once after the model is deleted.
in AbstractModel
at
line 184
callable[]
releaseAfterSaveCallbacks()
in AbstractModel
at
line 196
callable[]
releaseAfterDeleteCallbacks()
in AbstractModel
at
line 208
__call($method, $arguments)
{@inheritdoc}
in EventGeneratorTrait
at
line 24
raise(mixed $event)
Raise a new event.
in EventGeneratorTrait
at
line 34
array
releaseEvents()
Return and reset all pending events.
at
line 63
$this
read(int $number)
Mark the discussion as being read up to a certain point. Raises the DiscussionWasRead event.
at
line 80
BelongsTo
discussion()
Define the relationship with the discussion that this state is for.
at
line 90
BelongsTo
user()
Define the relationship with the user that this state is for.
at
line 101
protected Builder
setKeysForSaveQuery(Builder $query)
Set the keys for a save update query.