class Group extends AbstractModel

Traits

Constants

ADMINISTRATOR_ID

<p>The ID of the administrator group.</p>

GUEST_ID

<p>The ID of the guest group.</p>

MEMBER_ID

<p>The ID of the member group.</p>

MODERATOR_ID

<p>The ID of the mod group.</p>

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
protected array $pendingEvents from EventGeneratorTrait
int $id
string $name_singular
string $name_plural
string|null $color
string|null $icon
Collection $users
Collection $permissions

Methods

static 
boot()

<p>Boot the model.</p>

__construct(array $attributes = [])

<p>{@inheritdoc}</p>

array
getDates()

<p>Get the attributes that should be converted to dates.</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>

raise(mixed $event)

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

array
releaseEvents()

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

scopeWhereVisibleTo(Builder $query, User $actor)

<p>Scope a query to only include records that are visible to a user.</p>

static Group
build(string $nameSingular, string $namePlural, string $color, string $icon)

<p>Create a new group.</p>

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

<p>Rename the group.</p>

BelongsToMany
users()

<p>Define the relationship with the group's users.</p>

HasMany
permissions()

<p>Define the relationship with the group's permissions.</p>

bool
hasPermission(string $permission)

<p>Check whether the group has a certain permission.</p>

Details

static boot()

<p>Boot the model.</p>

__construct(array $attributes = [])

<p>{@inheritdoc}</p>

Parameters

array $attributes

array getDates()

<p>Get the attributes that should be converted to dates.</p>

Return Value

array

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

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

scopeWhereVisibleTo(Builder $query, User $actor)

<p>Scope a query to only include records that are visible to a user.</p>

Parameters

Builder $query
User $actor

static Group build(string $nameSingular, string $namePlural, string $color, string $icon)

<p>Create a new group.</p>

Parameters

string $nameSingular
string $namePlural
string $color
string $icon

Return Value

Group

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

<p>Rename the group.</p>

Parameters

string $nameSingular
string $namePlural

Return Value

$this

BelongsToMany users()

<p>Define the relationship with the group's users.</p>

Return Value

BelongsToMany

HasMany permissions()

<p>Define the relationship with the group's permissions.</p>

Return Value

HasMany

bool hasPermission(string $permission)

<p>Check whether the group has a certain permission.</p>

Parameters

string $permission

Return Value

bool