Role
extends Model
in package
Uses
Timezonable, SoftDelete
Clake\Userextended\Models\Role
Tags
Table of Contents
- $attachMany : mixed
- $attachOne : mixed
- $belongsTo : mixed
- $belongsToMany : mixed
- $code : string
- $created_at : Carbon|null
- $deleted_at : Carbon|null
- $description : string
- $group_id : int
- $hasMany : mixed
- $hasOne : array<string|int, mixed>
- $id : int
- $ignoreChecks : bool
- Provides an override for ignoring sort_order checks for onCreate, onUpdate, and onDelete
- $morphMany : mixed
- $morphOne : mixed
- $morphTo : mixed
- $name : string
- $sort_order : int
- $table : string
- $updated_at : Carbon|null
- $dates : array<string|int, mixed>
- $fillable : array<string|int, mixed>
- $forceDeleting : bool
- Indicates if the model is currently force deleting.
- $guarded : array<string|int, mixed>
- $timezonable : array<string|int, mixed>
- addUser() : bool
- Adds a role to a relational entry in UsersGroups
- all() :
- beforeCreate() : mixed
- Handles the automated settings of the sort order for roles.
- beforeDelete() : bool
- Handles the bubbling down of all the roles in a group when deleting an intermediate role
- beforeUpdate() : bool
- Ensures we aren't breaking the existing sort order by saving a sort order that doesn't make sense.
- bootSoftDelete() : void
- Boot the soft deleting trait for a model.
- bootTimezonable() : mixed
- Called by the system on runtime, Binds an event to the model to adjust timezones
- code() :
- forceDelete() : void
- Force a hard delete on a soft deleted model.
- get() :
- getDeletedAtColumn() : string
- Get the name of the "deleted at" column.
- getQualifiedDeletedAtColumn() : string
- Get the fully qualified "deleted at" column.
- getTime() : mixed
- Returns a timestamp adjusted by the logged in users Timezone
- getTimezonableAttributes() : array<string|int, mixed>
- Returns a collection of fields that will be encrypted.
- getUsersInRole() : array<string|int, mixed>|Collection
- Returns a collection of users which have a role
- isSoftDelete() : bool
- Helper method to check if the model is currently being hard or soft deleted, useful in events.
- newModelQuery() :
- newQuery() :
- onlyTrashed() : Builder|static
- Get a new query builder that only includes soft deletes.
- query() :
- removeUser() : bool
- Removes a user from a role TODO: Is this code right? Why is it 'adding' a user?
- restore() : bool|null
- Restore a soft-deleted model instance.
- restored() : void
- Register a restored model event with the dispatcher.
- restoring() : void
- Register a restoring model event with the dispatcher.
- rolesInGroup() :
- scopeCode() : mixed
- Returns the role with the passed in parameter code
- scopeRolesInGroup() : mixed
- Gets roles related to a group specified by the passed in parameter of groupCode
- timezonify() : mixed
- Returns a timestamp adjusted by the logged in users Timezone Alias for getTime()
- trashed() : bool
- Determine if the model instance has been soft-deleted.
- whereCode() :
- whereCreatedAt() :
- whereDeletedAt() :
- whereDescription() :
- whereGroupId() :
- whereId() :
- whereName() :
- whereSortOrder() :
- whereUpdatedAt() :
- withTrashed() : Builder|static
- Get a new query builder that includes soft deletes.
- performDeleteOnModel() : mixed
- Perform the actual delete query on this model instance.
- performRestoreOnRelations() : void
- Locates relations with softDelete flag and cascades the restore event.
- performSoftDeleteOnRelations() : void
- Locates relations with softDelete flag and cascades the delete event.
- runSoftDelete() : void
- Perform the actual delete query on this model instance.
Properties
$attachMany
public
mixed
$attachMany
= []
$attachOne
public
mixed
$attachOne
= []
$belongsTo
public
mixed
$belongsTo
= ['group' => ['Clake\UserExtended\Models\GroupsExtended', 'key' => 'group_id']]
$belongsToMany
public
mixed
$belongsToMany
= []
$code
public
string
$code
$created_at
public
Carbon|null
$created_at
$deleted_at
public
Carbon|null
$deleted_at
$description
public
string
$description
$group_id
public
int
$group_id
$hasMany
public
mixed
$hasMany
= []
$hasOne
public
array<string|int, mixed>
$hasOne
= []
Relations
$id
public
int
$id
$ignoreChecks
Provides an override for ignoring sort_order checks for onCreate, onUpdate, and onDelete
public
bool
$ignoreChecks
= false
$morphMany
public
mixed
$morphMany
= []
$morphOne
public
mixed
$morphOne
= []
$morphTo
public
mixed
$morphTo
= []
$name
public
string
$name
$sort_order
public
int
$sort_order
$table
public
string
$table
= 'clake_userextended_roles'
The database table used by the model.
$updated_at
public
Carbon|null
$updated_at
$dates
protected
array<string|int, mixed>
$dates
= ['deleted_at']
$fillable
protected
array<string|int, mixed>
$fillable
= []
Fillable fields
$forceDeleting
Indicates if the model is currently force deleting.
protected
bool
$forceDeleting
= false
$guarded
protected
array<string|int, mixed>
$guarded
= ['*']
Guarded fields
$timezonable
protected
array<string|int, mixed>
$timezonable
= ['updated_at', 'created_at']
Methods
addUser()
Adds a role to a relational entry in UsersGroups
public
static addUser( $userObj, $groupId, mixed $roleId) : bool
Parameters
Return values
bool —all()
public
static all(mixed $columns) :
Parameters
- $columns : mixed
Return values
—beforeCreate()
Handles the automated settings of the sort order for roles.
public
beforeCreate() : mixed
Return values
mixed —beforeDelete()
Handles the bubbling down of all the roles in a group when deleting an intermediate role
public
beforeDelete() : bool
Return values
bool —beforeUpdate()
Ensures we aren't breaking the existing sort order by saving a sort order that doesn't make sense.
public
beforeUpdate() : bool
Return values
bool —bootSoftDelete()
Boot the soft deleting trait for a model.
public
static bootSoftDelete() : void
Return values
void —bootTimezonable()
Called by the system on runtime, Binds an event to the model to adjust timezones
public
static bootTimezonable() : mixed
Tags
Return values
mixed —code()
public
static code(mixed $code) :
Parameters
- $code : mixed
Return values
—forceDelete()
Force a hard delete on a soft deleted model.
public
forceDelete() : void
Return values
void —get()
public
static get(mixed $columns) :
Parameters
- $columns : mixed
Return values
—getDeletedAtColumn()
Get the name of the "deleted at" column.
public
getDeletedAtColumn() : string
Return values
string —getQualifiedDeletedAtColumn()
Get the fully qualified "deleted at" column.
public
getQualifiedDeletedAtColumn() : string
Return values
string —getTime()
Returns a timestamp adjusted by the logged in users Timezone
public
getTime( $timestamp[, UserExtended|null $user = null ]) : mixed
Parameters
- $timestamp :
- $user : UserExtended|null = null
Return values
mixed —getTimezonableAttributes()
Returns a collection of fields that will be encrypted.
public
getTimezonableAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —getUsersInRole()
Returns a collection of users which have a role
public
getUsersInRole() : array<string|int, mixed>|Collection
Return values
array<string|int, mixed>|Collection —isSoftDelete()
Helper method to check if the model is currently being hard or soft deleted, useful in events.
public
isSoftDelete() : bool
Return values
bool —newModelQuery()
public
static newModelQuery() :
Return values
—newQuery()
public
static newQuery() :
Return values
—onlyTrashed()
Get a new query builder that only includes soft deletes.
public
static onlyTrashed() : Builder|static
Return values
Builder|static —query()
public
static query() :
Return values
—removeUser()
Removes a user from a role TODO: Is this code right? Why is it 'adding' a user?
public
static removeUser( $userObj, $groupId) : bool
Parameters
Return values
bool —restore()
Restore a soft-deleted model instance.
public
restore() : bool|null
Return values
bool|null —restored()
Register a restored model event with the dispatcher.
public
static restored(Closure|string $callback) : void
Parameters
- $callback : Closure|string
Return values
void —restoring()
Register a restoring model event with the dispatcher.
public
static restoring(Closure|string $callback) : void
Parameters
- $callback : Closure|string
Return values
void —rolesInGroup()
public
static rolesInGroup(mixed $groupCode) :
Parameters
- $groupCode : mixed
Return values
—scopeCode()
Returns the role with the passed in parameter code
public
scopeCode( $query, $code) : mixed
Parameters
Return values
mixed —scopeRolesInGroup()
Gets roles related to a group specified by the passed in parameter of groupCode
public
scopeRolesInGroup( $query, $groupCode) : mixed
Parameters
Return values
mixed —timezonify()
Returns a timestamp adjusted by the logged in users Timezone Alias for getTime()
public
timezonify( $timestamp) : mixed
Parameters
Return values
mixed —trashed()
Determine if the model instance has been soft-deleted.
public
trashed() : bool
Return values
bool —whereCode()
public
static whereCode(mixed $value) :
Parameters
- $value : mixed
Return values
—whereCreatedAt()
public
static whereCreatedAt(mixed $value) :
Parameters
- $value : mixed
Return values
—whereDeletedAt()
public
static whereDeletedAt(mixed $value) :
Parameters
- $value : mixed
Return values
—whereDescription()
public
static whereDescription(mixed $value) :
Parameters
- $value : mixed
Return values
—whereGroupId()
public
static whereGroupId(mixed $value) :
Parameters
- $value : mixed
Return values
—whereId()
public
static whereId(mixed $value) :
Parameters
- $value : mixed
Return values
—whereName()
public
static whereName(mixed $value) :
Parameters
- $value : mixed
Return values
—whereSortOrder()
public
static whereSortOrder(mixed $value) :
Parameters
- $value : mixed
Return values
—whereUpdatedAt()
public
static whereUpdatedAt(mixed $value) :
Parameters
- $value : mixed
Return values
—withTrashed()
Get a new query builder that includes soft deletes.
public
static withTrashed() : Builder|static
Return values
Builder|static —performDeleteOnModel()
Perform the actual delete query on this model instance.
protected
performDeleteOnModel() : mixed
Return values
mixed —performRestoreOnRelations()
Locates relations with softDelete flag and cascades the restore event.
protected
performRestoreOnRelations() : void
Return values
void —performSoftDeleteOnRelations()
Locates relations with softDelete flag and cascades the delete event.
protected
performSoftDeleteOnRelations() : void
Return values
void —runSoftDelete()
Perform the actual delete query on this model instance.
protected
runSoftDelete() : void