Role
extends Model
in package
uses
Sortable, HasFactory
Role Model
This model manages user roles and role-based access control for the security system. It stores role definitions, user associations, and permission relationships for implementing comprehensive role-based security functionality.
Table of Contents
Properties
- $fillable : array<string|int, string>
- The attributes that are mass assignable.
Methods
- __construct() : void
- Create a new Role model instance.
- getRoles() : Builder
- Get roles excluding the developer role.
- permissions() : BelongsToMany
- Get the permissions associated with this role.
- users() : BelongsToMany
- Get the users associated with this role.
Properties
$fillable
The attributes that are mass assignable.
protected
array<string|int, string>
$fillable
= ['role_name', 'role_description', 'current_status', 'role_type', 'created_by', 'updated_by', 'created_at', 'updated_at']
Methods
__construct()
Create a new Role model instance.
public
__construct() : void
Sets the table name from configuration constants.
getRoles()
Get roles excluding the developer role.
public
getRoles() : Builder
This function is used to get data based on role developer.
Return values
Builder —Query builder for roles excluding developer
permissions()
Get the permissions associated with this role.
public
permissions() : BelongsToMany
This function used to check permission for users. Establishes a many-to-many relationship with the Permission model.
Return values
BelongsToManyusers()
Get the users associated with this role.
public
users() : BelongsToMany
This function is used to get data for users. Establishes a many-to-many relationship with the User model.