UserRolesDb
extends BaseModel
in package
User roles DB model.
Tags
Table of Contents
Properties
- $allowedSort : array<string|int, mixed>
- $restrictedPriority : array<string|int, mixed>
- $tableName : string
Methods
- __construct() : mixed
- Class constructor
- __get() : mixed
- Magic __get
- add() : mixed
- Add user role data.
- delete() : bool
- Delete user roles with roles in `users_roles` table.
- get() : mixed
- Get a single role data.
- listItems() : array<string|int, mixed>
- List roles.
- update() : bool
- Update user role data.
- getNewPriority() : int
- Get new priority that is lowest between exists or restricted priorities.
Properties
$allowedSort
protected
array<string|int, mixed>
$allowedSort
= ['userrole_name', 'userrole_priority', 'userrole_create', 'userrole_create_gmt', 'userrole_lastupdate', 'userrole_lastupdate_gmt']
Allowed sort columns in db.
$restrictedPriority
protected
array<string|int, mixed>
$restrictedPriority
= [1, 9999, 10000]
Restrict priority that cannot re-order, delete them. The priority numbers in the array MUST be integer.
$tableName
protected
string
$tableName
Table name that already added prefix.
Methods
__construct()
Class constructor
public
__construct(Container $Container) : mixed
Parameters
- $Container : Container
Tags
__get()
Magic __get
public
__get(mixed $name) : mixed
Parameters
- $name : mixed
add()
Add user role data.
public
add(array<string|int, mixed> $data) : mixed
Parameters
- $data : array<string|int, mixed>
-
The associative array where key is column name and value is its value.
Return values
mixed —Return inserted ID if successfully inserted, return 0
(zero), or false
if failed to insert.
delete()
Delete user roles with roles in `users_roles` table.
public
delete(array<string|int, mixed> $roleIds) : bool
Parameters
- $roleIds : array<string|int, mixed>
-
The role IDs.
Return values
bool —Return true
on success, false
for otherwise.
get()
Get a single role data.
public
get([array<string|int, mixed> $where = [] ]) : mixed
Parameters
- $where : array<string|int, mixed> = []
-
The associative array where key is column name and value is its value.
Return values
mixed —Return object if result was found, return empty
, null
, false
if it was not found.
listItems()
List roles.
public
listItems([array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
- $options : array<string|int, mixed> = []
-
The associative array options. Available options keys:
search
(string) the search term,
roleIdsIn
(array) the role IDs to use in the sql commandWHERE IN (...)
where
(array) the where conditions where key is column name and value is its value,
sortOrders
(array) the sort order wheresort
key is column name,order
key is mysql order (ASC, DESC),
unlimited
(bool) set totrue
to show unlimited items, unset or set tofalse
to show limited items,
limit
(int) limit items per page. maximum is 100,
offset
(int) offset or start at record. 0 is first record,
Return values
array<string|int, mixed> —Return associative array with total
and items
in keys.
update()
Update user role data.
public
update(array<string|int, mixed> $data, array<string|int, mixed> $where) : bool
Parameters
- $data : array<string|int, mixed>
-
The associative array where its key is column name and value is its value to update.
- $where : array<string|int, mixed>
-
The associative array where its key is column name and value is its value.
Return values
bool —Return true
on success update, false
for otherwise.
getNewPriority()
Get new priority that is lowest between exists or restricted priorities.
protected
getNewPriority() : int