class Group extends AbstractModel

Traits

Constants

ADMINISTRATOR_ID

The ID of the administrator group.

GUEST_ID

The ID of the guest group.

MEMBER_ID

The ID of the member group.

MODERATOR_ID

The ID of the mod group.

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
int $id
string $name_singular
string $name_plural
string|null $color
string|null $icon
bool $is_hidden
Collection $users
Collection $permissions

Methods

static 
boot()

Boot the model.

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

scopeWhereVisibleTo(Builder $query, User $actor)

Scope a query to only include records that are visible to a user.

static Group
build(string $nameSingular, string $namePlural, string $color = null, string $icon = null, bool $isHidden = false)

Create a new group.

$this
rename(string $nameSingular, string $namePlural)

Rename the group.

BelongsToMany
users()

Define the relationship with the group's users.

HasMany
permissions()

Define the relationship with the group's permissions.

bool
hasPermission(string $permission)

Check whether the group has a certain permission.

Details

static boot()

Boot the model.

__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

scopeWhereVisibleTo(Builder $query, User $actor)

Scope a query to only include records that are visible to a user.

Parameters

Builder $query
User $actor

static Group build(string $nameSingular, string $namePlural, string $color = null, string $icon = null, bool $isHidden = false)

Create a new group.

Parameters

string $nameSingular
string $namePlural
string $color
string $icon
bool $isHidden

Return Value

Group

$this rename(string $nameSingular, string $namePlural)

Rename the group.

Parameters

string $nameSingular
string $namePlural

Return Value

$this

BelongsToMany users()

Define the relationship with the group's users.

Return Value

BelongsToMany

HasMany permissions()

Define the relationship with the group's permissions.

Return Value

HasMany

bool hasPermission(string $permission)

Check whether the group has a certain permission.

Parameters

string $permission

Return Value

bool