User
    
            
            in package
            
        
    
    
            
            uses
                            UsesRoles                    
    
Auth User ---- Class representing a user
Tags
Table of Contents
Properties
- $data : array<string|int, mixed>
- User Information
- $db : DB
- Internal instance of Leaf database
- $permissions : array<string|int, mixed>
- User Permissions
- $roles : array<string|int, mixed>
- User Roles
- $session : Session
- Internal instance of Leaf session
- $tokens : array<string|int, mixed>
- User Tokens
Methods
- __call() : Model
- Get a "user to many" table relation
- __construct() : mixed
- __get() : mixed
- __isset() : mixed
- __set() : mixed
- __toString() : mixed
- __unset() : mixed
- assign() : bool
- Assign new role to user
- can() : bool
- Check if user has a permission
- cannot() : bool
- Check if a user does not have a permission
- generateToken() : string
- Generate a new JWT for the user
- generateVerificationToken() : string
- Generate a verification token for the user
- get() : mixed
- getAuthInfo() : object
- Get auth information to be sent to the client
- id() : string|int
- Return the id of current user
- is() : bool
- Check if user has a role
- isNot() : bool
- Check if user does not have a role
- isVerified() : bool
- Check if email is verified
- permissions() : array<string|int, mixed>
- Return the user's permissions
- roles() : array<string|int, mixed>
- Return the user's roles
- setDb() : User
- Set user db instance
- tokens() : array<string|int, mixed>
- Return generated tokens
- unassign() : void
- Remove a role from a user
- verifyEmail() : bool
- Verify user's email
- getRolePermissions() : array<string|int, mixed>
- Get the permissions for a role
- setRolesAndPermissions() : void
- Set the roles and permissions for a user
Properties
$data
User Information
    protected
        array<string|int, mixed>
    $data
     = []
    
    
    
    
$db
Internal instance of Leaf database
    protected
        DB
    $db
    
    
    
    
    
$permissions
User Permissions
    protected
        array<string|int, mixed>
    $permissions
     = []
    
    
    
    
$roles
User Roles
    protected
        array<string|int, mixed>
    $roles
     = []
    
    
    
    
$session
Internal instance of Leaf session
    protected
        Session
    $session
    
    
    
    
    
$tokens
User Tokens
    protected
        array<string|int, mixed>
    $tokens
     = []
    
    
    
    
Methods
__call()
Get a "user to many" table relation
    public
                    __call(mixed $method, mixed $args) : Model
    
auth()->user()->orders()->all();
auth()->user()->transactions()->where('amount', '>', 100)->get();
auth()->user()->notes()->where('title', 'like', '%important%')->get();
auth()->user()->posts()->where('published', true)->all();
Parameters
- $method : mixed
- 
                    The table to relate to 
- $args : mixed
Tags
Return values
Model__construct()
    public
                    __construct(mixed $data[, mixed $session = true ]) : mixed
    Parameters
- $data : mixed
- $session : mixed = true
__get()
    public
                    __get(mixed $name) : mixed
    Parameters
- $name : mixed
__isset()
    public
                    __isset(mixed $name) : mixed
    Parameters
- $name : mixed
__set()
    public
                    __set(mixed $name, mixed $value) : mixed
    Parameters
- $name : mixed
- $value : mixed
__toString()
    public
                    __toString() : mixed
    __unset()
    public
                    __unset(mixed $name) : mixed
    Parameters
- $name : mixed
assign()
Assign new role to user
    public
                    assign(string|array<string|int, mixed> $role) : bool
    Parameters
- $role : string|array<string|int, mixed>
- 
                    The role to assign 
Return values
boolcan()
Check if user has a permission
    public
                    can(string|array<string|int, mixed> $permission) : bool
    Parameters
- $permission : string|array<string|int, mixed>
- 
                    The permission(s) to check 
Return values
boolcannot()
Check if a user does not have a permission
    public
                    cannot(mixed $permission) : bool
    Parameters
- $permission : mixed
Return values
boolgenerateToken()
Generate a new JWT for the user
    public
                    generateToken(mixed $tokenLifetime) : string
    Parameters
- $tokenLifetime : mixed
Return values
stringgenerateVerificationToken()
Generate a verification token for the user
    public
                    generateVerificationToken([mixed $expiresIn = null ]) : string
    Parameters
- $expiresIn : mixed = null
- 
                    Token expiration time 
Return values
stringget()
    public
                    get() : mixed
    getAuthInfo()
Get auth information to be sent to the client
    public
                    getAuthInfo() : object
    Return values
objectid()
Return the id of current user
    public
                    id() : string|int
    Return values
string|intis()
Check if user has a role
    public
                    is(string|array<string|int, mixed> $role) : bool
    Parameters
- $role : string|array<string|int, mixed>
- 
                    The role(s) to check 
Return values
boolisNot()
Check if user does not have a role
    public
                    isNot(mixed $role) : bool
    Parameters
- $role : mixed
Return values
boolisVerified()
Check if email is verified
    public
                    isVerified() : bool
    Return values
boolpermissions()
Return the user's permissions
    public
                    permissions() : array<string|int, mixed>
    Return values
array<string|int, mixed>roles()
Return the user's roles
    public
                    roles() : array<string|int, mixed>
    Return values
array<string|int, mixed>setDb()
Set user db instance
    public
                    setDb(Db $db) : User
    Parameters
- $db : Db
Return values
Usertokens()
Return generated tokens
    public
                    tokens() : array<string|int, mixed>
    Return values
array<string|int, mixed>unassign()
Remove a role from a user
    public
                    unassign(string|array<string|int, mixed> $role) : void
    Parameters
- $role : string|array<string|int, mixed>
- 
                    The role(s) to revoke 
verifyEmail()
Verify user's email
    public
                    verifyEmail() : bool
    Return values
boolgetRolePermissions()
Get the permissions for a role
    protected
                    getRolePermissions(mixed $roles) : array<string|int, mixed>
    Parameters
- $roles : mixed
Return values
array<string|int, mixed>setRolesAndPermissions()
Set the roles and permissions for a user
    protected
                    setRolesAndPermissions(string|array<string|int, mixed> $roles) : void
    Parameters
- $roles : string|array<string|int, mixed>
- 
                    The role(s) to set