class Channel extends Model (View source)

Traits

Methods to make a model "followable" per user.

Methods to manage a model's icon attribute.

Methods to manage permissions on a model.

Methods to give a model per-user state.

Methods for models that can be a part of the forum "structure", like channels, pages, links, and headings.

Methods to associate uploaded images with a model.

Properties

static protected $unguarded from  Model
Collection read-only $followedBy from  Followable
Collection read-only $ignoredBy from  Followable
string $icon from  HasIcon
?string $icon_file

The path to the icon file, if the icon is the file type.

from  HasIcon
PermissionCollection read-only $permissions from  HasPermissions
Structure read-only $structure from  Structurable
static protected Formatter[] $formatters from  UsesFormatter
$timestamps
protected $casts
int $id
string $name
string $slug
?string $description
?string $instructions
?array $filters
?string $layout
?array $layout_config
bool $ignore
bool $answerable
?array $translations
?int $posts_reaction_set_id
?int $comments_reaction_set_id
Collection read-only $posts
Collection read-only $newPosts
Collection read-only $unreadPosts
ChannelUser read-only $userState
ReactionSet read-only $postsReactionSet
ReactionSet read-only $commentsReactionSet
string read-only $url
string read-only $edit_url

Methods

getConnectionName()

No description

from  Model
BelongsToMany
followedBy()

Relationship with all users who are following this model.

BelongsToMany
ignoredBy()

Relationship with all users who are ignoring this model.

void
scopeFollowing(Builder $query)

Find only models that the current user is following.

void
scopeIgnoring(Builder $query)

No description

void
setNotifications(string|null $value)

Save the current user's notification preference for this model.

void
follow()

Follow this model for the current user.

void
unfollow()

Unfollow this model for the current user.

void
ignore()

Ignore this model for the current user.

void
unignore()

Unignore this model for the current user.

bool
isFollowed()

Whether the current user is following this model.

bool
isIgnored()

No description

void
saveIcon(array $icon)

Save the icon using input from an component.

from  HasIcon
Attribute
iconFile()

No description

from  HasIcon
static void
bootHasPermissions()

No description

MorphMany
permissions()

Relationship with the permission records pertaining to this model.

array
abilities()

No description

array
defaultAbilities()

No description

void
savePermissions(array|null $grid)

Save the permissions to the database.

bool
isPublic(string $ability = 'view')

No description

static array|null
allPermitted(User|null $user, string $ability = 'view')

Get the model IDs that the given user has permission for.

HasOne
userState(User $user = null)

Relationship with the state record for a user.

loadUserState(User $user)

Load the userState relationship for the given user.

static void
bootStructurable()

No description

MorphOne
structure()

Relationship with the node for this model within the forum structure.

HtmlString|string
format(string $attribute, User $user = null)

Render an attribute as HTML for the given user.

static Formatter
getFormatter(string $attribute)

Set a formatter instance for this model.

static void
setFormatter(string $attribute, Formatter $formatter)

Set a formatter instance for this model.

getAttribute($key)

No description

setAttribute($key, $value)

No description

static void
booting()

No description

HasMany
posts()

Relationship with the channel's posts.

HasMany
unreadPosts()

Relationship with posts that are followed and contain unread content.

void
scopeWithNewPostsCount(Builder $query)

Scope to select count of posts that are new since a channel was followed.

HasMany
newPosts()

Relationship with posts that are new since this channel was followed.

BelongsTo
postsReactionSet()

No description

BelongsTo
commentsReactionSet()

No description

BelongsToMany
taxonomies()

No description

Attribute
url()

No description

Attribute
editUrl()

No description

array
streamUpdated()

Get the Turbo Streams that should be sent when this post is updated.

Details

getConnectionName()

No description

BelongsToMany followedBy()

Relationship with all users who are following this model.

Return Value

BelongsToMany

BelongsToMany ignoredBy()

Relationship with all users who are ignoring this model.

Return Value

BelongsToMany

void scopeFollowing(Builder $query)

Find only models that the current user is following.

Parameters

Builder $query

Return Value

void

void scopeIgnoring(Builder $query)

No description

Parameters

Builder $query

Return Value

void

protected void setNotifications(string|null $value)

Save the current user's notification preference for this model.

Parameters

string|null $value

Return Value

void

void follow()

Follow this model for the current user.

Return Value

void

void unfollow()

Unfollow this model for the current user.

Return Value

void

void ignore()

Ignore this model for the current user.

Return Value

void

void unignore()

Unignore this model for the current user.

Return Value

void

bool isFollowed()

Whether the current user is following this model.

Return Value

bool

bool isIgnored()

No description

Return Value

bool

void saveIcon(array $icon)

Save the icon using input from an component.

Parameters

array $icon

Return Value

void

protected Attribute iconFile()

No description

Return Value

Attribute

static void bootHasPermissions()

No description

Return Value

void

MorphMany permissions()

Relationship with the permission records pertaining to this model.

Return Value

MorphMany

array abilities()

No description

Return Value

array

array defaultAbilities()

No description

Return Value

array

void savePermissions(array|null $grid)

Save the permissions to the database.

Parameters

array|null $grid

Return Value

void

bool isPublic(string $ability = 'view')

No description

Parameters

string $ability

Return Value

bool

static array|null allPermitted(User|null $user, string $ability = 'view')

Get the model IDs that the given user has permission for.

If the user is an admin, the result will be null, meaning there is no restriction on the models they have permission for.

Parameters

User|null $user
string $ability

Return Value

array|null

HasOne userState(User $user = null)

Relationship with the state record for a user.

Defaults to the current user when no user is specified, as is the case when eager-loading the relationship.

The model representing the user state table is derived by appending User to the parent model name (eg. PostUser). Alternatively, it can be specified by setting the userStateModel property.

Parameters

User $user

Return Value

HasOne

HasUserState loadUserState(User $user)

Load the userState relationship for the given user.

Parameters

User $user

Return Value

HasUserState

static void bootStructurable()

No description

Return Value

void

MorphOne structure()

Relationship with the node for this model within the forum structure.

Return Value

MorphOne

HtmlString|string format(string $attribute, User $user = null)

Render an attribute as HTML for the given user.

Parameters

string $attribute
User $user

Return Value

HtmlString|string

static Formatter getFormatter(string $attribute)

Set a formatter instance for this model.

Parameters

string $attribute

Return Value

Formatter

static void setFormatter(string $attribute, Formatter $formatter)

Set a formatter instance for this model.

Parameters

string $attribute
Formatter $formatter

Return Value

void

getAttribute($key)

No description

Parameters

$key

setAttribute($key, $value)

No description

Parameters

$key
$value

static protected void booting()

No description

Return Value

void

HasMany posts()

Relationship with the channel's posts.

Return Value

HasMany

HasMany unreadPosts()

Relationship with posts that are followed and contain unread content.

Return Value

HasMany

void scopeWithNewPostsCount(Builder $query)

Scope to select count of posts that are new since a channel was followed.

Parameters

Builder $query

Return Value

void

HasMany newPosts()

Relationship with posts that are new since this channel was followed.

Return Value

HasMany

BelongsTo postsReactionSet()

No description

Return Value

BelongsTo

BelongsTo commentsReactionSet()

No description

Return Value

BelongsTo

BelongsToMany taxonomies()

No description

Return Value

BelongsToMany

protected Attribute url()

No description

Return Value

Attribute

protected Attribute editUrl()

No description

Return Value

Attribute

array streamUpdated()

Get the Turbo Streams that should be sent when this post is updated.

Return Value

array