class LabelTree extends Model

A label tree is a group of labels. Projects can choose to used different label trees, which are then offered for labeling things in the project.

Label trees have admins and editors as members. Editors can add and delete labels. Admins can also manage members and modify the tree (name, visibility etc). Label trees can be public or private. Private trees maintain a list of projects that are authorized to use the tree. This list is maintained by label tree admins.

Properties

protected array $hidden The attributes hidden from the model's JSON form.
protected array $casts The attributes that should be casted to native types.

Methods

bool
memberCanLooseAdminStatus(User $member)

Check if a member can loose their admin status.

Builder
scopePublicTrees(Builder $query)

Scope a query to public label trees.

Builder
scopePrivateTrees(Builder $query)

Scope a query to private label trees.

Builder
scopeAccessibleBy(Builder $query, User $user)

Scope a query to all trees that are accessible by a user.

BelongsTo
visibility()

The visibility of the label tree.

BelongsToMany
members()

The members of this label tree. Every member has a tree-specific role.

HasMany
labels()

The labels that belong to this tree.

bool
canBeDeleted()

Determines if the label tree can be safely deleted.

addMember(User|id $user, Role|int $role)

Add a new member with a certain role.

updateMember(User|int $user, Role|int $role)

Update a member (role).

bool
memberCanBeRemoved(User $member)

Determines if a member can be removed.

BelongsToMany
projects()

The projects that are using this label tree.

BelongsToMany
authorizedProjects()

The projects that are authorized to use this private label tree.

detachUnauthorizedProjects()

Detaches all projects that are not among the authorized projects.

Details

at line 44
bool memberCanLooseAdminStatus(User $member)

Check if a member can loose their admin status.

Parameters

User $member

Return Value

bool

at line 58
Builder scopePublicTrees(Builder $query)

Scope a query to public label trees.

Parameters

Builder $query

Return Value

Builder

at line 69
Builder scopePrivateTrees(Builder $query)

Scope a query to private label trees.

Parameters

Builder $query

Return Value

Builder

at line 81
Builder scopeAccessibleBy(Builder $query, User $user)

Scope a query to all trees that are accessible by a user.

Parameters

Builder $query
User $user

Return Value

Builder

at line 117
BelongsTo visibility()

The visibility of the label tree.

Return Value

BelongsTo

at line 127
BelongsToMany members()

The members of this label tree. Every member has a tree-specific role.

Return Value

BelongsToMany

at line 139
HasMany labels()

The labels that belong to this tree.

Return Value

HasMany

at line 151
bool canBeDeleted()

Determines if the label tree can be safely deleted.

A label tree can be safely deleted if none if its labels is in use.

Return Value

bool

at line 167
addMember(User|id $user, Role|int $role)

Add a new member with a certain role.

Parameters

User|id $user
Role|int $role

at line 186
updateMember(User|int $user, Role|int $role)

Update a member (role).

Parameters

User|int $user
Role|int $role

at line 207
bool memberCanBeRemoved(User $member)

Determines if a member can be removed.

A member can be removed if at least one admin member remains afterwards.

Parameters

User $member

Return Value

bool

at line 217
BelongsToMany projects()

The projects that are using this label tree.

Return Value

BelongsToMany

at line 227
BelongsToMany authorizedProjects()

The projects that are authorized to use this private label tree.

Return Value

BelongsToMany

at line 235
detachUnauthorizedProjects()

Detaches all projects that are not among the authorized projects.